Skip to content

Commit

Permalink
add - doc - Added four strings from RFC6715
Browse files Browse the repository at this point in the history
---

We've added four vCard 4.0 properties to the parser as specified in the RFC6715 document.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 2, 2024
1 parent e3e7e6a commit d07d599
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions VisualCard/Parsers/VcardConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,9 @@ internal static class VcardConstants
internal const string _memberSpecifier = "MEMBER";
internal const string _relatedSpecifier = "RELATED";
internal const string _clientPidMapSpecifier = "CLIENTPIDMAP";
internal const string _expertiseSpecifier = "EXPERTISE";
internal const string _hobbySpecifier = "HOBBY";
internal const string _interestSpecifier = "INTEREST";
internal const string _orgDirectorySpecifier = "ORG-DIRECTORY";
}
}
16 changes: 16 additions & 0 deletions VisualCard/Parsers/VcardParserTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ internal static bool StringSupported(StringsEnum stringsEnum, Version cardVersio
StringsEnum.ContactUri => cardVersion.Major >= 4,
StringsEnum.Member => kind == "group" && cardVersion.Major == 4,
StringsEnum.Related => cardVersion.Major == 4,
StringsEnum.Expertise => cardVersion.Major >= 4,
StringsEnum.Hobby => cardVersion.Major >= 4,
StringsEnum.Interest => cardVersion.Major >= 4,
StringsEnum.OrgDirectory => cardVersion.Major >= 4,
_ =>
throw new InvalidOperationException("Invalid string enumeration type to get supported value"),
};
Expand Down Expand Up @@ -119,6 +123,10 @@ internal static string GetPrefixFromStringsEnum(StringsEnum stringsEnum) =>
StringsEnum.ContactUri => VcardConstants._contactUriSpecifier,
StringsEnum.Member => VcardConstants._memberSpecifier,
StringsEnum.Related => VcardConstants._relatedSpecifier,
StringsEnum.Expertise => VcardConstants._expertiseSpecifier,
StringsEnum.Hobby => VcardConstants._hobbySpecifier,
StringsEnum.Interest => VcardConstants._interestSpecifier,
StringsEnum.OrgDirectory => VcardConstants._orgDirectorySpecifier,
_ =>
throw new NotImplementedException($"String enumeration {stringsEnum} is not implemented.")
};
Expand Down Expand Up @@ -172,6 +180,10 @@ internal static PartCardinality GetStringsEnumFromType(StringsEnum strings, Vers
StringsEnum.ContactUri => PartCardinality.Any,
StringsEnum.Member => PartCardinality.Any,
StringsEnum.Related => PartCardinality.Any,
StringsEnum.Expertise => PartCardinality.Any,
StringsEnum.Hobby => PartCardinality.Any,
StringsEnum.Interest => PartCardinality.Any,
StringsEnum.OrgDirectory => PartCardinality.Any,
_ => throw new ArgumentException($"There is no string enum info for {strings}"),
};
}
Expand Down Expand Up @@ -265,6 +277,10 @@ internal static (PartType type, object enumeration, Type? enumType, Func<string,
VcardConstants._contactUriSpecifier => (PartType.Strings, StringsEnum.ContactUri, null, null, "", "", "uri", [], []),
VcardConstants._memberSpecifier => (PartType.Strings, StringsEnum.Member, null, null, "", "", "uri", [], []),
VcardConstants._relatedSpecifier => (PartType.Strings, StringsEnum.Related, null, null, "", "", "uri", [], []),
VcardConstants._expertiseSpecifier => (PartType.Strings, StringsEnum.Expertise, null, null, "", "", "text", [], []),
VcardConstants._hobbySpecifier => (PartType.Strings, StringsEnum.Hobby, null, null, "", "", "text", [], []),
VcardConstants._interestSpecifier => (PartType.Strings, StringsEnum.Interest, null, null, "", "", "text", [], []),
VcardConstants._orgDirectorySpecifier => (PartType.Strings, StringsEnum.OrgDirectory, null, null, "", "", "uri", [], []),

// Extensions are allowed
VcardConstants._xSpecifier => (PartType.PartsArray, PartsArrayEnum.NonstandardNames, typeof(XNameInfo), XNameInfo.FromStringVcardStatic, "", "", "", [], []),
Expand Down
16 changes: 16 additions & 0 deletions VisualCard/Parts/Enums/StringsEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,21 @@ public enum StringsEnum
/// The related member URI
/// </summary>
Related,
/// <summary>
/// Contact's field of expertise
/// </summary>
Expertise,
/// <summary>
/// Contact's hobby
/// </summary>
Hobby,
/// <summary>
/// Contact's interest
/// </summary>
Interest,
/// <summary>
/// Contact organization directory
/// </summary>
OrgDirectory,
}
}

0 comments on commit d07d599

Please sign in to comment.