Esempio n. 1
0
        /// <summary>
        /// Parse exactly 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>
        /// <exception cref="KeyNotFoundException">
        /// Fields of <see cref="SubEvent"/> and fields of <paramref name="format"/> doesn't match
        /// </exception>
        public static SubEvent ParseExact(EntryHeader format, bool isComment, string fields)
        {
            var re = new SubEvent();

            re.ParseExact(fields, format);
            re.IsComment = isComment;
            return(re);
        }
Esempio n. 2
0
 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);
         }
     }
 }