diff --git a/.editorconfig b/.editorconfig index 053e56b..6c289ef 100644 --- a/.editorconfig +++ b/.editorconfig @@ -46,3 +46,7 @@ end_of_line = crlf insert_final_newline = true indent_style = space indent_size = 2 + +[*.vcf] +insert_final_newline = true +indent_style = tab diff --git a/VisualCard.ShowContacts/Properties/launchSettings.json b/VisualCard.ShowContacts/Properties/launchSettings.json index 4b29e91..badb941 100644 --- a/VisualCard.ShowContacts/Properties/launchSettings.json +++ b/VisualCard.ShowContacts/Properties/launchSettings.json @@ -23,6 +23,10 @@ "vCard 5.0 test (with agents)": { "commandName": "Project", "commandLineArgs": "TestFiles/fourVCard5Agents.vcf" + }, + "vCard - Picture test": { + "commandName": "Project", + "commandLineArgs": "TestFiles/picture.vcf" } } } \ No newline at end of file diff --git a/VisualCard.ShowContacts/TestFiles/fourVCard4.vcf b/VisualCard.ShowContacts/TestFiles/fourVCard4.vcf index 943e2bc..d81191d 100644 --- a/VisualCard.ShowContacts/TestFiles/fourVCard4.vcf +++ b/VisualCard.ShowContacts/TestFiles/fourVCard4.vcf @@ -15,7 +15,12 @@ IMPP;TYPE=HOME:aim:IM IMPP;TYPE=HOME:msn:Windows LIVE IMPP;TYPE=HOME:ymsgr:Yahoo N:Navasquillo;Neville;Neville\,Nevile;Mr.;Jr. -N;ALTID=0;LANGUAGE=de:NAVASQUILLO;Neville;Neville\,Nevile;Mr.;Jr. +N;ALTID=0;LANGUAGE=de: + NAVASQUILLO; + Neville; + Neville\,Nevile; + Mr.; + Jr. NOTE:Notes ORG:Organization TEL;TYPE=work:098-765-4321 @@ -24,7 +29,8 @@ TEL;TYPE=voice:078-494-6434 TEL;TYPE=home:348-404-8404 TITLE:Title GENDER:M -X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;NVL.N;1;;;;;;;;;;;;; +X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;NVL.N;1 + ;;;;;;;;;;;;; END:VCARD BEGIN:VCARD diff --git a/VisualCard.ShowContacts/TestFiles/fourVCard5Agents.vcf b/VisualCard.ShowContacts/TestFiles/fourVCard5Agents.vcf index 001bf0b..3f71745 100644 --- a/VisualCard.ShowContacts/TestFiles/fourVCard5Agents.vcf +++ b/VisualCard.ShowContacts/TestFiles/fourVCard5Agents.vcf @@ -53,7 +53,15 @@ IMPP:aim:john.s N:Sanders;John;;; NOTE:Note test for VisualCard ORG:Acme Co. -AGENT:BEGIN:VCARD\nVERSION:5.0\nFN:Joe Friday\nN:Friday;Joe;;;\nTEL:+1-919-555-7878\nTITLE:Area Administrator\, Assistant\nEMAIL\;TYPE=INTERNET:jfriday@host.com\nEND:VCARD\n +AGENT: + BEGIN:VCARD\n + VERSION:5.0\n + FN:Joe Friday\n + N:Friday;Joe;;;\n + TEL:+1-919-555-7878\n + TITLE:Area Administrator\, Assistant\n + EMAIL\;TYPE=INTERNET:jfriday@host.com\n + END:VCARD\n TEL;TYPE=cell:495-522-3560 TITLE:Product Manager X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;JS;1;;;;;;;;;;;;; diff --git a/VisualCard.ShowContacts/TestFiles/picture.vcf b/VisualCard.ShowContacts/TestFiles/picture.vcf new file mode 100644 index 0000000..c0e76ff --- /dev/null +++ b/VisualCard.ShowContacts/TestFiles/picture.vcf @@ -0,0 +1,248 @@ +BEGIN:VCARD +VERSION:2.1 +N:ViceCity;EoflaOE;;; +FN:EoflaOE ViceCity +X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname;AptiviCEO;;;;;;;;;;;;;; +PHOTO;ENCODING=BASE64;PNG:iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAA + AXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAACAASURBVHichX1ps2XJVd3K4Yx3eEMNXa2eh + CSEaIxtZAMy2EQYGySDQ8YjAeFgCGGHA4fxX/D/8xd/tMETGix1V9Ub7nDuPUNm+sMeTp77qi + E7pKpX795zctx77b3X3mkMvpbAzcAgIcEZh4SElBISEuqiRj/2aKsV+vGM0pXoQ4+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zMSqDn7Lj + 6GZryQO2xuKqvsbr4+dcuOnIEmDH7yQRKND6XYq79jVO01wvb1tvsTvv8GL9Uoub5+DCSkfz+ + pm1r/VC5bmzs2KSB+hVVWzIINsJEgPN7wxTmkfWZgfW3PLJp4sdCq5GkuF4PI06lY50x7v4mC + mlRdV2Sj6k07xmMtkQBjUEu7GDtXaROSTKflNvUWd3TK64VEHtG01klzELnH/NpfKFACFz+/8 + B5VQAT8Q/6EUAAAAASUVORK5CYII= + +END:VCARD diff --git a/VisualCard.ShowContacts/VisualCard.ShowContacts.csproj b/VisualCard.ShowContacts/VisualCard.ShowContacts.csproj index 968fb81..a99f206 100644 --- a/VisualCard.ShowContacts/VisualCard.ShowContacts.csproj +++ b/VisualCard.ShowContacts/VisualCard.ShowContacts.csproj @@ -26,23 +26,7 @@ - - - - - - Always - - - Always - - - Always - - - Always - - + Always diff --git a/VisualCard/CardTools.cs b/VisualCard/CardTools.cs index e8e5fb3..fbd29e4 100644 --- a/VisualCard/CardTools.cs +++ b/VisualCard/CardTools.cs @@ -23,6 +23,7 @@ using VisualCard.Parsers; using System; using VisualCard.Parts; +using Textify.General; namespace VisualCard { @@ -79,6 +80,8 @@ public static Card[] GetCards(StreamReader stream) CardLine = stream.ReadLine(); while (!stream.EndOfStream) { + bool append = false; + // Skip empty lines if (string.IsNullOrEmpty(CardLine)) { @@ -90,7 +93,9 @@ public static Card[] GetCards(StreamReader stream) else if (CardLine != VcardConstants._beginText && !CardLine.StartsWith(VcardConstants._versionSpecifier) && CardLine != VcardConstants._endText) - CardContent.AppendLine(CardLine); + append = true; + if (append) + CardContent.Append(CardLine); // All VCards must begin with BEGIN:VCARD if (CardLine != VcardConstants._beginText && !BeginSpotted) @@ -126,7 +131,9 @@ public static Card[] GetCards(StreamReader stream) EndSpotted = true; // Make a new parser instance - VcardParser CardParser = new(CardContent.ToString(), CardVersion); + string content = CardContent.ToString(); + string[] contentLines = content.SplitNewLines(); + VcardParser CardParser = new(contentLines, CardVersion); FinalParsers.Add(CardParser); // Clear the content in case we want to make a second contact @@ -134,6 +141,8 @@ public static Card[] GetCards(StreamReader stream) BeginSpotted = false; CardLine = stream.ReadLine(); } + else if (append) + CardContent.AppendLine(); } // Close the stream to avoid stuck file handle diff --git a/VisualCard/Parsers/VcardConstants.cs b/VisualCard/Parsers/VcardConstants.cs index 47595e6..601433b 100644 --- a/VisualCard/Parsers/VcardConstants.cs +++ b/VisualCard/Parsers/VcardConstants.cs @@ -26,6 +26,10 @@ internal static class VcardConstants internal const string _endText = "END:VCARD"; internal const string _versionSpecifier = "VERSION"; + // Misc vCard constants + internal const string _spaceBreak = " "; + internal const string _tabBreak = "\x0009"; + // Available in vCard 2.1, 3.0, 4.0, and 5.0 internal const char _fieldDelimiter = ';'; internal const char _valueDelimiter = ','; diff --git a/VisualCard/Parsers/VcardParser.cs b/VisualCard/Parsers/VcardParser.cs index b326b3e..ac5f3f2 100644 --- a/VisualCard/Parsers/VcardParser.cs +++ b/VisualCard/Parsers/VcardParser.cs @@ -25,6 +25,7 @@ using System.Reflection; using System.Text; using System.Text.RegularExpressions; +using Textify.General; using VisualCard.Exceptions; using VisualCard.Parts; using VisualCard.Parts.Enums; @@ -39,44 +40,60 @@ namespace VisualCard.Parsers internal class VcardParser { private readonly Version cardVersion = new(); - private readonly string cardContent = ""; + private readonly string[] cardContent = []; /// /// VCard card content /// - public virtual string CardContent => + public string[] CardContent => cardContent; /// /// VCard card version /// - public virtual Version CardVersion => + public Version CardVersion => cardVersion; /// /// Parses a VCard contact /// /// A strongly-typed instance holding information about the card - public virtual Card Parse() + public Card Parse() { // Check the content to ensure that we really have data - if (string.IsNullOrEmpty(CardContent)) + if (CardContent.Length == 0) throw new InvalidDataException($"Card content is empty."); - // Now, make a stream out of card content - byte[] CardContentData = Encoding.Default.GetBytes(CardContent); - MemoryStream CardContentStream = new(CardContentData, false); - StreamReader CardContentReader = new(CardContentStream); - // Make a new vCard var card = new Card(CardVersion); // Iterate through all the lines - int lineNumber = 0; - while (!CardContentReader.EndOfStream) + bool constructing = false; + StringBuilder valueBuilder = new(); + for (int i = 0; i < CardContent.Length; i++) { // Get line - string _value = CardContentReader.ReadLine(); - lineNumber += 1; + string _value = CardContent[i]; + int lineNumber = i + 1; + if (string.IsNullOrEmpty(_value)) + continue; + + // First, check to see if we need to construct blocks + string secondLine = i + 1 < CardContent.Length ? CardContent[i + 1] : ""; + bool firstConstructedLine = !_value.StartsWith(VcardConstants._spaceBreak) && !_value.StartsWith(VcardConstants._tabBreak); + constructing = secondLine.StartsWithAnyOf([VcardConstants._spaceBreak, VcardConstants._tabBreak]); + secondLine = secondLine.Length > 1 ? secondLine.Substring(1) : ""; + if (constructing) + { + if (firstConstructedLine) + valueBuilder.Append(_value); + valueBuilder.Append(secondLine); + continue; + } + else if (!firstConstructedLine) + { + _value = valueBuilder.ToString(); + valueBuilder.Clear(); + } // Variables string value = _value.Substring(_value.IndexOf(VcardConstants._argumentDelimiter) + 1); @@ -186,8 +203,8 @@ public virtual Card Parse() // Now, get the part info var partInfo = isWithType ? - fromStringMethod.Invoke(null, [_value, finalArgs.ToArray(), altId, CardVersion, CardContentReader]) : - fromStringMethod.Invoke(null, [_value, altId, CardVersion, CardContentReader]); + fromStringMethod.Invoke(null, [_value, finalArgs.ToArray(), altId, CardVersion]) : + fromStringMethod.Invoke(null, [_value, altId, CardVersion]); card.SetPart(partsType, (BaseCardPartInfo)partInfo); } break; @@ -205,8 +222,8 @@ public virtual Card Parse() // Now, get the part info var partInfo = isWithType ? - fromStringMethod.Invoke(null, [_value, finalArgs.ToArray(), altId, CardVersion, CardContentReader]) : - fromStringMethod.Invoke(null, [_value, altId, CardVersion, CardContentReader]); + fromStringMethod.Invoke(null, [_value, finalArgs.ToArray(), altId, CardVersion]) : + fromStringMethod.Invoke(null, [_value, altId, CardVersion]); card.AddPartToArray(partsArrayType, (BaseCardPartInfo)partInfo); } break; @@ -266,7 +283,7 @@ internal void ValidateCard(Card card) throw new InvalidDataException($"The following keys [{string.Join(", ", expectedFields)}] are required. Got [{string.Join(", ", actualFields)}]."); } - internal VcardParser(string cardContent, Version cardVersion) + internal VcardParser(string[] cardContent, Version cardVersion) { this.cardContent = cardContent; this.cardVersion = cardVersion; diff --git a/VisualCard/Parts/BaseCardPartInfo.cs b/VisualCard/Parts/BaseCardPartInfo.cs index 73bc453..1030212 100644 --- a/VisualCard/Parts/BaseCardPartInfo.cs +++ b/VisualCard/Parts/BaseCardPartInfo.cs @@ -89,9 +89,9 @@ public override int GetHashCode() public static bool operator !=(BaseCardPartInfo left, BaseCardPartInfo right) => !(left == right); - internal abstract BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader); + internal abstract BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion); - internal abstract BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader); + internal abstract BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion); internal abstract string ToStringVcardInternal(Version cardVersion); } diff --git a/VisualCard/Parts/Implementations/AddressInfo.cs b/VisualCard/Parts/Implementations/AddressInfo.cs index 7d035ad..07ce452 100644 --- a/VisualCard/Parts/Implementations/AddressInfo.cs +++ b/VisualCard/Parts/Implementations/AddressInfo.cs @@ -66,11 +66,11 @@ public class AddressInfo : BaseCardPartInfo, IEquatable /// public string Country { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new AddressInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new AddressInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new AddressInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new AddressInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -105,7 +105,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string adrValue = value.Substring(VcardConstants._addressSpecifier.Length + 1); @@ -120,7 +120,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo([], splitAddressValues, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string adrValue = value.Substring(VcardConstants._addressSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/AgentInfo.cs b/VisualCard/Parts/Implementations/AgentInfo.cs index 4e39937..f0c02ef 100644 --- a/VisualCard/Parts/Implementations/AgentInfo.cs +++ b/VisualCard/Parts/Implementations/AgentInfo.cs @@ -40,11 +40,11 @@ public class AgentInfo : BaseCardPartInfo, IEquatable /// public Card[] AgentCards { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new AgentInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new AgentInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new AgentInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new AgentInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -74,7 +74,7 @@ internal override string ToStringVcardInternal(Version cardVersion) return agents.ToString(); } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string agentValue = value.Substring(VcardConstants._agentSpecifier.Length + 1); @@ -89,7 +89,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(agentValue, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string agentValue = value.Substring(VcardConstants._agentSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/AnniversaryInfo.cs b/VisualCard/Parts/Implementations/AnniversaryInfo.cs index 74224bd..007a310 100644 --- a/VisualCard/Parts/Implementations/AnniversaryInfo.cs +++ b/VisualCard/Parts/Implementations/AnniversaryInfo.cs @@ -37,16 +37,16 @@ public class AnniversaryInfo : BaseCardPartInfo, IEquatable /// public DateTime? Anniversary { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new AnniversaryInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new AnniversaryInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new AnniversaryInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new AnniversaryInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) => $"{VcardConstants._anniversarySpecifier}:{Anniversary:yyyyMMdd}"; - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string anniversaryValue = value.Substring(VcardConstants._anniversarySpecifier.Length + 1); @@ -55,8 +55,8 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(anniversaryValue); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) => + FromStringVcardInternal(value, altId, cardVersion); private AnniversaryInfo InstallInfo(string value) { diff --git a/VisualCard/Parts/Implementations/BirthDateInfo.cs b/VisualCard/Parts/Implementations/BirthDateInfo.cs index 5507d32..1b3726a 100644 --- a/VisualCard/Parts/Implementations/BirthDateInfo.cs +++ b/VisualCard/Parts/Implementations/BirthDateInfo.cs @@ -37,16 +37,16 @@ public class BirthDateInfo : BaseCardPartInfo, IEquatable /// public DateTime? BirthDate { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new BirthDateInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new BirthDateInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new BirthDateInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new BirthDateInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) => $"{VcardConstants._birthSpecifier}:{BirthDate:yyyyMMdd}"; - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string bdayValue = value.Substring(VcardConstants._birthSpecifier.Length + 1); @@ -55,7 +55,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(bdayValue, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string bdayValue = value.Substring(value.IndexOf(VcardConstants._argumentDelimiter) + 1); diff --git a/VisualCard/Parts/Implementations/CategoryInfo.cs b/VisualCard/Parts/Implementations/CategoryInfo.cs index 4865013..097db14 100644 --- a/VisualCard/Parts/Implementations/CategoryInfo.cs +++ b/VisualCard/Parts/Implementations/CategoryInfo.cs @@ -38,11 +38,11 @@ public class CategoryInfo : BaseCardPartInfo, IEquatable /// public string[] Category { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new CategoryInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new CategoryInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new CategoryInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new CategoryInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -51,7 +51,7 @@ internal override string ToStringVcardInternal(Version cardVersion) $"{Category}"; } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string categoryValue = value.Substring(VcardConstants._categoriesSpecifier.Length + 1); @@ -60,8 +60,8 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(categoryValue); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) => + FromStringVcardInternal(value, altId, cardVersion); private CategoryInfo InstallInfo(string value) { diff --git a/VisualCard/Parts/Implementations/EmailInfo.cs b/VisualCard/Parts/Implementations/EmailInfo.cs index 9773759..c2cec0a 100644 --- a/VisualCard/Parts/Implementations/EmailInfo.cs +++ b/VisualCard/Parts/Implementations/EmailInfo.cs @@ -42,11 +42,11 @@ public class EmailInfo : BaseCardPartInfo, IEquatable /// public string ContactEmailAddress { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new EmailInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new EmailInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new EmailInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new EmailInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -69,7 +69,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string mailValue = value.Substring(VcardConstants._emailSpecifier.Length + 1); @@ -79,7 +79,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(splitMail, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string mailValue = value.Substring(VcardConstants._emailSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/GenderInfo.cs b/VisualCard/Parts/Implementations/GenderInfo.cs index 6609bfc..b1d7894 100644 --- a/VisualCard/Parts/Implementations/GenderInfo.cs +++ b/VisualCard/Parts/Implementations/GenderInfo.cs @@ -42,18 +42,18 @@ public class GenderInfo : BaseCardPartInfo, IEquatable /// public string GenderDescription { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new GenderInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new GenderInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new GenderInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new GenderInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) => $"{VcardConstants._genderSpecifier}{VcardConstants._argumentDelimiter}" + (Gender != Gender.Unspecified ? Gender.ToString()[0] : "") + (!string.IsNullOrEmpty(GenderDescription) ? $"{VcardConstants._fieldDelimiter}{GenderDescription}" : ""); - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string genderValue = value.Substring(VcardConstants._genderSpecifier.Length + 1); @@ -62,8 +62,8 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(genderValue); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) => + FromStringVcardInternal(value, altId, cardVersion); private GenderInfo InstallInfo(string value) { diff --git a/VisualCard/Parts/Implementations/GeoInfo.cs b/VisualCard/Parts/Implementations/GeoInfo.cs index 582232b..3eeaf19 100644 --- a/VisualCard/Parts/Implementations/GeoInfo.cs +++ b/VisualCard/Parts/Implementations/GeoInfo.cs @@ -42,11 +42,11 @@ public class GeoInfo : BaseCardPartInfo, IEquatable /// public string Geo { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new GeoInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new GeoInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new GeoInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new GeoInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -68,7 +68,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string geoValue = value.Substring(VcardConstants._geoSpecifier.Length + 1); @@ -78,7 +78,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo([_geoStr], false, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string geoValue = value.Substring(VcardConstants._geoSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/ImppInfo.cs b/VisualCard/Parts/Implementations/ImppInfo.cs index aba5ec2..0d0915a 100644 --- a/VisualCard/Parts/Implementations/ImppInfo.cs +++ b/VisualCard/Parts/Implementations/ImppInfo.cs @@ -42,11 +42,11 @@ public class ImppInfo : BaseCardPartInfo, IEquatable /// public string[] ImppTypes { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new ImppInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new ImppInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new ImppInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new ImppInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -71,7 +71,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string imppValue = value.Substring(VcardConstants._imppSpecifier.Length + 1); @@ -81,7 +81,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(_imppTypes, imppValue, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { bool specifierRequired = cardVersion.Major >= 3; diff --git a/VisualCard/Parts/Implementations/LabelAddressInfo.cs b/VisualCard/Parts/Implementations/LabelAddressInfo.cs index 7ce5c32..95a52fa 100644 --- a/VisualCard/Parts/Implementations/LabelAddressInfo.cs +++ b/VisualCard/Parts/Implementations/LabelAddressInfo.cs @@ -42,11 +42,11 @@ public class LabelAddressInfo : BaseCardPartInfo, IEquatable /// public string DeliveryLabel { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new LabelAddressInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new LabelAddressInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new LabelAddressInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new LabelAddressInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -69,7 +69,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string adrValue = value.Substring(VcardConstants._labelSpecifier.Length + 1); @@ -84,7 +84,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(splitAdr, splitAddressValues, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string adrValue = value.Substring(VcardConstants._labelSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/LogoInfo.cs b/VisualCard/Parts/Implementations/LogoInfo.cs index e1e3bdc..7a63dd0 100644 --- a/VisualCard/Parts/Implementations/LogoInfo.cs +++ b/VisualCard/Parts/Implementations/LogoInfo.cs @@ -50,11 +50,11 @@ public class LogoInfo : BaseCardPartInfo, IEquatable /// public string LogoEncoded { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new LogoInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new LogoInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new LogoInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new LogoInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -104,10 +104,10 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) => + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) => throw new InvalidDataException("Logo field must not have empty type."); - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string logoValue = value.Substring(VcardConstants._logoSpecifier.Length + 1); @@ -116,16 +116,15 @@ internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, throw new InvalidDataException("Logo field must specify exactly two values (Type and arguments, and logo information)"); // Populate the fields - return InstallInfo(splitLogo, finalArgs, altId, cardVersion, cardContentReader); + return InstallInfo(splitLogo, finalArgs, altId, cardVersion); } - private LogoInfo InstallInfo(string[] splitLogo, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + private LogoInfo InstallInfo(string[] splitLogo, string[] finalArgs, int altId, Version cardVersion) { bool altIdSupported = cardVersion.Major >= 4; // Check to see if the value is prepended by the VALUE= argument string valueType = VcardParserTools.GetValuesString(splitLogo, "", VcardConstants._valueArgumentSpecifier).ToLower(); - bool isUrl = valueType == "url" || valueType == "uri"; // Check to see if the value is prepended by the ENCODING= argument string logoEncoding = VcardParserTools.GetValuesString(splitLogo, "BASE64", VcardConstants._encodingArgumentSpecifier); @@ -133,24 +132,8 @@ private LogoInfo InstallInfo(string[] splitLogo, string[] finalArgs, int altId, // Check to see if the value is prepended with the TYPE= argument string logoType = VcardParserTools.GetTypesString(splitLogo, "JPEG", false); - // Now, get the encoded logo - StringBuilder encodedLogo = new(); - if (splitLogo.Length == 2) - encodedLogo.Append(splitLogo[1]); - - // Make sure to get all the blocks until we reach an empty line - if (!isUrl) - { - string lineToBeAppended = cardContentReader.ReadLine(); - while (!string.IsNullOrWhiteSpace(lineToBeAppended) && lineToBeAppended.StartsWith(" ")) - { - encodedLogo.Append(lineToBeAppended.Trim()); - lineToBeAppended = cardContentReader.ReadLine(); - } - } - // Populate the fields - LogoInfo _logo = new(altIdSupported ? altId : 0, altIdSupported ? finalArgs : [], valueType, logoEncoding, logoType, encodedLogo.ToString()); + LogoInfo _logo = new(altIdSupported ? altId : 0, altIdSupported ? finalArgs : [], valueType, logoEncoding, logoType, splitLogo[1]); return _logo; } diff --git a/VisualCard/Parts/Implementations/NameInfo.cs b/VisualCard/Parts/Implementations/NameInfo.cs index ebb1f2d..90b6032 100644 --- a/VisualCard/Parts/Implementations/NameInfo.cs +++ b/VisualCard/Parts/Implementations/NameInfo.cs @@ -54,11 +54,11 @@ public class NameInfo : BaseCardPartInfo, IEquatable /// public string[] Suffixes { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new NameInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new NameInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new NameInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new NameInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -94,7 +94,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Check the line string nameValue = value.Substring(VcardConstants._nameSpecifier.Length + 1); @@ -106,7 +106,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(splitName, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Check the line string nameValue = value.Substring(VcardConstants._nameSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/NicknameInfo.cs b/VisualCard/Parts/Implementations/NicknameInfo.cs index 535df6f..09c748c 100644 --- a/VisualCard/Parts/Implementations/NicknameInfo.cs +++ b/VisualCard/Parts/Implementations/NicknameInfo.cs @@ -42,11 +42,11 @@ public class NicknameInfo : BaseCardPartInfo, IEquatable /// public string[] NicknameTypes { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new NicknameInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new NicknameInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new NicknameInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new NicknameInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -70,7 +70,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string nickValue = value.Substring(VcardConstants._nicknameSpecifier.Length + 1); @@ -79,7 +79,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo([nickValue], altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string nickValue = value.Substring(VcardConstants._nicknameSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/OrganizationInfo.cs b/VisualCard/Parts/Implementations/OrganizationInfo.cs index 40a3dfb..6daccfe 100644 --- a/VisualCard/Parts/Implementations/OrganizationInfo.cs +++ b/VisualCard/Parts/Implementations/OrganizationInfo.cs @@ -50,11 +50,11 @@ public class OrganizationInfo : BaseCardPartInfo, IEquatable /// public string Role { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new OrganizationInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new OrganizationInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new OrganizationInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new OrganizationInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -83,7 +83,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string orgValue = value.Substring(VcardConstants._orgSpecifier.Length + 1); @@ -93,7 +93,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(splitOrg, ["WORK"], altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { bool specifierRequired = cardVersion.Major >= 3; diff --git a/VisualCard/Parts/Implementations/PhotoInfo.cs b/VisualCard/Parts/Implementations/PhotoInfo.cs index 48e9ecf..6f2e962 100644 --- a/VisualCard/Parts/Implementations/PhotoInfo.cs +++ b/VisualCard/Parts/Implementations/PhotoInfo.cs @@ -50,11 +50,11 @@ public class PhotoInfo : BaseCardPartInfo, IEquatable /// public string PhotoEncoded { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new PhotoInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new PhotoInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new PhotoInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new PhotoInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -104,10 +104,10 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) => + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) => throw new InvalidDataException("Photo field must not have empty type."); - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string photoValue = value.Substring(VcardConstants._photoSpecifier.Length + 1); @@ -116,16 +116,15 @@ internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, throw new InvalidDataException("Photo field must specify exactly two values (Type and arguments, and photo information)"); // Populate the fields - return InstallInfo(splitPhoto, finalArgs, altId, cardVersion, cardContentReader); + return InstallInfo(splitPhoto, finalArgs, altId, cardVersion); } - private PhotoInfo InstallInfo(string[] splitPhoto, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + private PhotoInfo InstallInfo(string[] splitPhoto, string[] finalArgs, int altId, Version cardVersion) { bool altIdSupported = cardVersion.Major >= 4; // Check to see if the value is prepended by the VALUE= argument string valueType = VcardParserTools.GetValuesString(splitPhoto, "", VcardConstants._valueArgumentSpecifier).ToLower(); - bool isUrl = valueType == "url" || valueType == "uri"; // Check to see if the value is prepended by the ENCODING= argument string photoEncoding = VcardParserTools.GetValuesString(splitPhoto, "BASE64", VcardConstants._encodingArgumentSpecifier); @@ -133,24 +132,8 @@ private PhotoInfo InstallInfo(string[] splitPhoto, string[] finalArgs, int altId // Check to see if the value is prepended with the TYPE= argument string photoType = VcardParserTools.GetTypesString(splitPhoto, "JPEG", false); - // Now, get the encoded photo - StringBuilder encodedPhoto = new(); - if (splitPhoto.Length == 2) - encodedPhoto.Append(splitPhoto[1]); - - // Make sure to get all the blocks until we reach an empty line - if (!isUrl) - { - string lineToBeAppended = cardContentReader.ReadLine(); - while (!string.IsNullOrWhiteSpace(lineToBeAppended) && lineToBeAppended.StartsWith(" ")) - { - encodedPhoto.Append(lineToBeAppended.Trim()); - lineToBeAppended = cardContentReader.ReadLine(); - } - } - // Populate the fields - PhotoInfo _photo = new(altIdSupported ? altId : 0, altIdSupported ? finalArgs : [], valueType, photoEncoding, photoType, encodedPhoto.ToString()); + PhotoInfo _photo = new(altIdSupported ? altId : 0, altIdSupported ? finalArgs : [], valueType, photoEncoding, photoType, splitPhoto[1]); return _photo; } diff --git a/VisualCard/Parts/Implementations/RevisionInfo.cs b/VisualCard/Parts/Implementations/RevisionInfo.cs index 907d3ab..674eefe 100644 --- a/VisualCard/Parts/Implementations/RevisionInfo.cs +++ b/VisualCard/Parts/Implementations/RevisionInfo.cs @@ -37,16 +37,16 @@ public class RevisionInfo : BaseCardPartInfo, IEquatable /// public DateTime? Revision { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new RevisionInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new RevisionInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new RevisionInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new RevisionInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) => $"{VcardConstants._revSpecifier}:{Revision:yyyy-MM-dd HH:mm:ss}"; - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string revValue = value.Substring(VcardConstants._revSpecifier.Length + 1); @@ -55,8 +55,8 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(revValue, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) => + FromStringVcardInternal(value, altId, cardVersion); private RevisionInfo InstallInfo(string value, int altId, Version cardVersion) => InstallInfo(value, [], altId, cardVersion); diff --git a/VisualCard/Parts/Implementations/RoleInfo.cs b/VisualCard/Parts/Implementations/RoleInfo.cs index 94376f8..f14fde6 100644 --- a/VisualCard/Parts/Implementations/RoleInfo.cs +++ b/VisualCard/Parts/Implementations/RoleInfo.cs @@ -37,11 +37,11 @@ public class RoleInfo : BaseCardPartInfo, IEquatable /// public string ContactRole { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new RoleInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new RoleInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new RoleInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new RoleInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -63,7 +63,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string roleValue = value.Substring(VcardConstants._roleSpecifier.Length + 1); @@ -72,7 +72,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(roleValue, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string roleValue = value.Substring(VcardConstants._roleSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/SoundInfo.cs b/VisualCard/Parts/Implementations/SoundInfo.cs index 8b793f5..6685d0f 100644 --- a/VisualCard/Parts/Implementations/SoundInfo.cs +++ b/VisualCard/Parts/Implementations/SoundInfo.cs @@ -50,11 +50,11 @@ public class SoundInfo : BaseCardPartInfo, IEquatable /// public string SoundEncoded { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new SoundInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new SoundInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new SoundInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new SoundInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -104,10 +104,10 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) => + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) => throw new InvalidDataException("Sound field must not have empty type."); - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string soundValue = value.Substring(VcardConstants._soundSpecifier.Length + 1); @@ -116,16 +116,15 @@ internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, throw new InvalidDataException("Sound field must specify exactly two values (Type and arguments, and sound information)"); // Populate the fields - return InstallInfo(splitSound, finalArgs, altId, cardVersion, cardContentReader); + return InstallInfo(splitSound, finalArgs, altId, cardVersion); } - private SoundInfo InstallInfo(string[] splitSound, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + private SoundInfo InstallInfo(string[] splitSound, string[] finalArgs, int altId, Version cardVersion) { bool altIdSupported = cardVersion.Major >= 4; // Check to see if the value is prepended by the VALUE= argument string valueType = VcardParserTools.GetValuesString(splitSound, "", VcardConstants._valueArgumentSpecifier).ToLower(); - bool isUrl = valueType == "url" || valueType == "uri"; // Check to see if the value is prepended by the ENCODING= argument string soundEncoding = VcardParserTools.GetValuesString(splitSound, "BASE64", VcardConstants._encodingArgumentSpecifier); @@ -133,24 +132,8 @@ private SoundInfo InstallInfo(string[] splitSound, string[] finalArgs, int altId // Check to see if the value is prepended with the TYPE= argument string soundType = VcardParserTools.GetTypesString(splitSound, "WAVE", false); - // Now, get the encoded sound - StringBuilder encodedSound = new(); - if (splitSound.Length == 2) - encodedSound.Append(splitSound[1]); - - // Make sure to get all the blocks until we reach an empty line - if (!isUrl) - { - string lineToBeAppended = cardContentReader.ReadLine(); - while (!string.IsNullOrWhiteSpace(lineToBeAppended)) - { - encodedSound.Append(lineToBeAppended); - lineToBeAppended = cardContentReader.ReadLine()?.Trim(); - } - } - // Populate the fields - SoundInfo _sound = new(altIdSupported ? altId : 0, altIdSupported ? finalArgs : [], valueType, soundEncoding, soundType, encodedSound.ToString()); + SoundInfo _sound = new(altIdSupported ? altId : 0, altIdSupported ? finalArgs : [], valueType, soundEncoding, soundType, splitSound[1]); return _sound; } diff --git a/VisualCard/Parts/Implementations/TelephoneInfo.cs b/VisualCard/Parts/Implementations/TelephoneInfo.cs index 6c29426..4ba7f7a 100644 --- a/VisualCard/Parts/Implementations/TelephoneInfo.cs +++ b/VisualCard/Parts/Implementations/TelephoneInfo.cs @@ -42,11 +42,11 @@ public class TelephoneInfo : BaseCardPartInfo, IEquatable /// public string ContactPhoneNumber { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new TelephoneInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new TelephoneInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new TelephoneInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new TelephoneInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -69,7 +69,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string telValue = value.Substring(VcardConstants._telephoneSpecifier.Length + 1); @@ -78,7 +78,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo([telValue], altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string telValue = value.Substring(VcardConstants._telephoneSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/TimeDateZoneInfo.cs b/VisualCard/Parts/Implementations/TimeDateZoneInfo.cs index 68140b2..0187ce8 100644 --- a/VisualCard/Parts/Implementations/TimeDateZoneInfo.cs +++ b/VisualCard/Parts/Implementations/TimeDateZoneInfo.cs @@ -42,11 +42,11 @@ public class TimeDateZoneInfo : BaseCardPartInfo, IEquatable /// public string TimeZone { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new TimeDateZoneInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new TimeDateZoneInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new TimeDateZoneInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new TimeDateZoneInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -68,7 +68,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string tzValue = value.Substring(VcardConstants._timeZoneSpecifier.Length + 1); @@ -77,7 +77,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo([tzValue], false, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Check the line string tzValue = value.Substring(VcardConstants._timeZoneSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/TitleInfo.cs b/VisualCard/Parts/Implementations/TitleInfo.cs index c717b51..91c0d84 100644 --- a/VisualCard/Parts/Implementations/TitleInfo.cs +++ b/VisualCard/Parts/Implementations/TitleInfo.cs @@ -38,11 +38,11 @@ public class TitleInfo : BaseCardPartInfo, IEquatable /// public string ContactTitle { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new TitleInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new TitleInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new TitleInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new TitleInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -64,7 +64,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string titleValue = value.Substring(VcardConstants._titleSpecifier.Length + 1); @@ -73,7 +73,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo([titleValue], altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string titleValue = value.Substring(VcardConstants._titleSpecifier.Length + 1); diff --git a/VisualCard/Parts/Implementations/XNameInfo.cs b/VisualCard/Parts/Implementations/XNameInfo.cs index d9e41cb..821110c 100644 --- a/VisualCard/Parts/Implementations/XNameInfo.cs +++ b/VisualCard/Parts/Implementations/XNameInfo.cs @@ -45,11 +45,11 @@ public class XNameInfo : BaseCardPartInfo, IEquatable /// public string[] XValues { get; } - internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion, StreamReader cardContentReader) => - new XNameInfo().FromStringVcardInternal(value, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardStatic(string value, int altId, Version cardVersion) => + new XNameInfo().FromStringVcardInternal(value, altId, cardVersion); - internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) => - new XNameInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion, cardContentReader); + internal static BaseCardPartInfo FromStringVcardWithTypeStatic(string value, string[] finalArgs, int altId, Version cardVersion) => + new XNameInfo().FromStringVcardWithTypeInternal(value, finalArgs, altId, cardVersion); internal override string ToStringVcardInternal(Version cardVersion) { @@ -75,7 +75,7 @@ internal override string ToStringVcardInternal(Version cardVersion) } } - internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardInternal(string value, int altId, Version cardVersion) { // Get the value string xValue = value.Substring(VcardConstants._xSpecifier.Length); @@ -85,7 +85,7 @@ internal override BaseCardPartInfo FromStringVcardInternal(string value, int alt return InstallInfo(splitX, altId, cardVersion); } - internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion, StreamReader cardContentReader) + internal override BaseCardPartInfo FromStringVcardWithTypeInternal(string value, string[] finalArgs, int altId, Version cardVersion) { // Get the value string xValue = value.Substring(VcardConstants._xSpecifier.Length);