/// <summary> /// Writes the list of entry names to the specified writer in the specified format. /// </summary> /// <param name="writer">The stream writer to the entries to write to.</param> /// <param name="format">The format to write the entries in.</param> public void SaveList(StreamWriter writer, KifintListFormat format) { var list = new KifintList(this); var ordered = Entries.Values.OrderBy(e => e.FileName); switch (format) { case KifintListFormat.Text: writer.Write(list.FilePath); for (int i = 0; i < list.Entries.Count; i++) { writer.WriteLine(list.Entries[i]); } break; case KifintListFormat.Csv: writer.Write(list.FilePath); for (int i = 0; i < list.Entries.Count; i++) { writer.Write(','); writer.Write(list.Entries[i]); } break; case KifintListFormat.Json: writer.Write(JsonConvert.SerializeObject(list)); break; default: throw new ArgumentException($"{nameof(format)} is undefined!"); } }
/// <summary> /// Writes the list of entry names to the specified file in the specified format. /// </summary> /// <param name="path">The file path to the entries to write to.</param> /// <param name="format">The format to write the entries in.</param> public void SaveList(string path, KifintListFormat format) { using (StreamWriter writer = new StreamWriter(path)) SaveList(writer, format); }