public static Task SaveFileAsSingle <T>(this ISimpleJsonFile simpleJsonFile, string filePath, T model, bool indented) { if (model == null) { return(Task.FromResult(0)); } return(simpleJsonFile.SaveFile(filePath, new T[] { model }, indented)); }
public static async Task AppendFile <T>(this ISimpleJsonFile simpleJsonFile, string filePath, IList <T> list, bool indented) { if (string.IsNullOrWhiteSpace(filePath) || list == null || list.Count == 0) { return; } var saveItems = new List <T>(); var currents = await simpleJsonFile.ReadFile <T>(filePath).ConfigureAwait(false); if (currents != null) { saveItems.AddRange(currents); } saveItems.AddRange(list); await simpleJsonFile.SaveFile(filePath, saveItems, indented).ConfigureAwait(false); }