From a1c27653118aa22d43069810ba009b76b3bb8f76 Mon Sep 17 00:00:00 2001 From: Daniel Hitzel Date: Fri, 21 Jan 2022 15:05:31 +0100 Subject: [PATCH] Add support for Multiple Values in multiple lines --- iCalNET/Model/vEvent.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/iCalNET/Model/vEvent.cs b/iCalNET/Model/vEvent.cs index 12ce5d4..6fce6c5 100644 --- a/iCalNET/Model/vEvent.cs +++ b/iCalNET/Model/vEvent.cs @@ -14,19 +14,31 @@ public class vEvent private const string ContentLinePattern = "(.+?):(.+?)(?=\\r\\n[A-Z]|$)"; private const RegexOptions ContentLineTRegexOptions = RegexOptions.Singleline; - public Dictionary ContentLines { get; set; } + public Dictionary> ContentLines { get; set; } public vEvent(string source) { Match contentMatch = Regex.Match(source, vEventContentPattern, vEventContentRegexOptions); string content = contentMatch.Groups[1].ToString(); MatchCollection matches = Regex.Matches(content, ContentLinePattern, ContentLineTRegexOptions); - ContentLines = new Dictionary(); + ContentLines = new Dictionary>(); foreach (Match match in matches) { - string contentLineString = match.Groups[0].ToString(); + string contentLineString = match.Groups[0].ToString(); ContentLine contentLine = new ContentLine(contentLineString); - ContentLines[contentLine.Name] = contentLine; + if (ContentLines.ContainsKey(ContentLine.name)) + { + ContentLines[contentLine.Name].Add(contentLine); + d[i.ToString()].Add(i.ToString()); + } + else + { + ContentLines.Add(contentLine.name, new List() + { + contentLine + } + ); + } } }