Skip to content

Commit

Permalink
Merge branch 'main' into vertrag
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein authored Aug 21, 2024
2 parents 6b54362 + 4827897 commit a28e754
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions BO4E/BO/Marktlokation.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -449,7 +450,7 @@ public class Marktlokation : BusinessObject
/// </summary>
/// <param name="id">id to test</param>
/// <returns></returns>
public static bool ValidateId(string id)
public static bool ValidateId(string? id)
{
if (string.IsNullOrWhiteSpace(id))
{
Expand All @@ -460,9 +461,8 @@ public static bool ValidateId(string id)
{
return false;
}

var expectedChecksum = GetChecksum(id);
var actualChecksum = id.Substring(10, 1);
var expectedChecksum = GetChecksum(id!);
var actualChecksum = id!.Substring(10, 1);
return actualChecksum == expectedChecksum;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static EicType GetEICType(string type)
/// </summary>
/// <param name="eicCandidate"></param>
/// <returns>true iff it obeys the "Allgemeine Bildungsvorschrift"</returns>
public static bool IsValidEIC(this string eicCandidate)
public static bool IsValidEIC(this string? eicCandidate)
{
if (string.IsNullOrWhiteSpace(eicCandidate))
{
Expand All @@ -110,7 +110,7 @@ public static bool IsValidEIC(this string eicCandidate)
}

var actualCheckCharacter = eicCandidate.Last();
var expectedCheckCharacter = GetEICCheckCharacter(eicCandidate[..15]);
var expectedCheckCharacter = GetEICCheckCharacter(eicCandidate![..15]);
return actualCheckCharacter == expectedCheckCharacter;
}

Expand All @@ -119,7 +119,7 @@ public static bool IsValidEIC(this string eicCandidate)
/// </summary>
/// <param name="eicCandidate"></param>
/// <returns>true iff BDEW is the "Vergeber"</returns>
public static bool IsValidEICBDEW(this string eicCandidate)
public static bool IsValidEICBDEW(this string? eicCandidate)
{
if (!IsValidEIC(eicCandidate))
{
Expand All @@ -137,23 +137,23 @@ public static bool IsValidEICBDEW(this string eicCandidate)
/// <param name="bilanzierungsGebietEic"></param>
/// <returns></returns>
/// <remarks>See https://bdew-codes.de/Content/Files/EIC/Awh_20171218_EIC-Vergabe_V1-0.pdf section 2.2.2</remarks>
public static bool IsValidBilanzierungsGebietId(this string bilanzierungsGebietEic)
public static bool IsValidBilanzierungsGebietId(this string? bilanzierungsGebietEic)
{
if (!IsValidEICBDEW(bilanzierungsGebietEic))
{
return false;
}

var eicType = GetEICType(EicRegex.Match(bilanzierungsGebietEic).Groups["typ"].Value);
return eicType == EicType.AREA && GermanControlAreas.ContainsKey(bilanzierungsGebietEic.Substring(3, 1));
return eicType == EicType.AREA && GermanControlAreas.ContainsKey(bilanzierungsGebietEic!.Substring(3, 1));
}

/// <summary>
/// returns true if <paramref name="eicCode"/> is a German Control Area / Regelzone
/// </summary>
/// <param name="eicCode"></param>
/// <returns></returns>
public static bool IsGermanControlArea(this string eicCode) => GermanControlAreas.Values.Contains(eicCode);
public static bool IsGermanControlArea(this string? eicCode) => GermanControlAreas.Values.Contains(eicCode);

private static readonly Dictionary<string, string> GermanControlAreas = new()
{
Expand Down Expand Up @@ -265,4 +265,4 @@ private static char NumberToEicCharacter(int number)
};
}
}
}
}

0 comments on commit a28e754

Please sign in to comment.