/// <summary> /// Parse from <paramref name="fields"/>. /// </summary> /// <param name="fields">A <see cref="string"/> of fields that seperates with ','.</param> /// <param name="format">The <see cref="EntryHeader"/> presents its format.</param> /// <param name="isComment">Whether the <see cref="SubEvent"/> is comment or not.</param> /// <returns><see cref="SubEvent"/> presents the <paramref name="fields"/>.</returns> /// <exception cref="ArgumentNullException">Parameters are null or empty.</exception> /// <exception cref="FormatException">Deserialize failed for some fields.</exception> public static SubEvent Parse(EntryHeader format, bool isComment, string fields) { var re = new SubEvent(); re.Parse(fields, format); re.IsComment = isComment; return(re); }
private void initEvent(string eventLine) { if (FormatHelper.TryPraseLine(out var key, out var value, eventLine)) { if (string.Equals(key, "format", StringComparison.OrdinalIgnoreCase)) { this.eventFormat = new EntryHeader(value); } else { if (this.eventFormat == null) { this.eventFormat = DefaultEventFormat; } var sub = this.isExact ? SubEvent.ParseExact(this.eventFormat, string.Equals(key, "comment", StringComparison.OrdinalIgnoreCase), value) : SubEvent.Parse(this.eventFormat, string.Equals(key, "comment", StringComparison.OrdinalIgnoreCase), value); this.subtitle.EventCollection.Add(sub); } } }