/// <summary> /// Make CsvClause from Clause. /// </summary> public static CsvClause MapToCsvClause(this Clause cl) { if (cl is null) { throw new ArgumentNullException(nameof(cl)); } return(new CsvClause { Id = cl.Id, Sound = cl.Sound, Word = cl.Word, Transcription = cl.Transcription, Translations = cl.Translations .OrderBy(o => o.Index) .Aggregate("", (s, o) => s += $"{TranslationConverter.ConvertToString(o)}{TranslationsSeparator} ") .TrimEnd(' ', TranslationsSeparator), Context = cl.Context, Relations = MakeRelationsString(cl.Relations), Added = cl.Added, Updated = cl.Updated, Watched = cl.Watched, WatchedCount = cl.WatchedCount, Group = cl.Group.ToGradeStr() }); }
/// <summary> /// Get a string representation of the translations. /// </summary> public static string MakeTranslationsString(IEnumerable <Translation> translations) { if (translations?.Any() != true) { return(""); } return(translations.OrderBy(o => o.Index) .Aggregate("", (s, o) => s += $"{TranslationConverter.ConvertToString(o)}; ") .TrimEnd(' ', ';')); }