Esempio n. 1
0
 internal StringBuilder ToString(StringBuilder sb, LyricsFormat format)
 {
     var datasource = this.AsEnumerable();
     if (format.Flag(LyricsFormat.LinesSortByContent))
         datasource = datasource.OrderBy(l => l.Content);
     if (format.Flag(LyricsFormat.LinesSortByTimestamp))
         datasource = (datasource is IOrderedEnumerable<TLine> od)
             ? od.ThenBy(l => l.InternalTimestamp)
             : datasource.OrderBy(l => l.InternalTimestamp);
     if (format.Flag(LyricsFormat.MergeTimestamp))
     {
         foreach (var item in datasource.GroupBy(l => l.Content))
         {
             foreach (var line in item)
             {
                 line.TimestampToString(sb);
             }
             sb.AppendLine(item.Key);
         }
     }
     else
     {
         foreach (var item in datasource)
         {
             item.ToString(sb).AppendLine();
         }
     }
     return sb;
 }
Esempio n. 2
0
 public static bool Flag(this LyricsFormat value, LyricsFormat flag)
 {
     return((value & flag) == flag);
 }