Skip to content

Commit

Permalink
add - Added kind check for array types (vCard)
Browse files Browse the repository at this point in the history
---

We've added checking for matching kind. However, this is not used yet.

---

Type: add
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 29, 2024
1 parent c4a8abf commit 7946c79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion VisualCard/Parsers/VcardParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public Card Parse()
bool constructing = false;
StringBuilder valueBuilder = new();
string[] allowedTypes = ["HOME", "WORK", "PREF"];
string kind = "individual";
for (int i = 0; i < CardContent.Length; i++)
{
// Get line
Expand Down Expand Up @@ -184,7 +185,10 @@ public Card Parse()

// Let VisualCard know that we've explicitly specified a kind.
if (stringType == StringsEnum.Kind)
{
kind = finalValue;
card.kindExplicitlySpecified = true;
}

// Set the string for real
card.SetString(stringType, finalValue);
Expand All @@ -194,7 +198,7 @@ public Card Parse()
{
PartsArrayEnum partsArrayType = (PartsArrayEnum)enumeration;
Type? partsArrayClass = classType;
bool supported = VcardParserTools.EnumArrayTypeSupported(partsArrayType, CardVersion);
bool supported = VcardParserTools.EnumArrayTypeSupported(partsArrayType, CardVersion, kind);
if (!supported)
continue;
if (fromString is null)
Expand Down
2 changes: 1 addition & 1 deletion VisualCard/Parsers/VcardParserTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ internal static bool StringSupported(StringsEnum stringsEnum, Version cardVersio
throw new InvalidOperationException("Invalid string enumeration type to get supported value"),
};

internal static bool EnumArrayTypeSupported(PartsArrayEnum partsArrayEnum, Version cardVersion) =>
internal static bool EnumArrayTypeSupported(PartsArrayEnum partsArrayEnum, Version cardVersion, string kind) =>
partsArrayEnum switch
{
PartsArrayEnum.Names => true,
Expand Down

0 comments on commit 7946c79

Please sign in to comment.