public async Task SetValue(string id, Package <TValue>?value) { Dictionary <string, FileItemValue>?list = await ListLoader.GetData().ConfigureAwait(false); if (list == null) { return; } if (list.TryGetValue(id, out FileItemValue? item)) { await Set(item, value).ConfigureAwait(false); if (value == null) { _ = list.Remove(id); await ListLoader.Save(list).ConfigureAwait(false); } } else if (value != null) { FileItemValue nitem = new FileItemValue { FileName = id }; await Set(nitem, value).ConfigureAwait(false); list.Add(id, nitem); await ListLoader.Save(list).ConfigureAwait(false); } }
private Task Set(FileItemValue item, Package <TValue>?value) { FileInfo fi = new FileInfo(Path.Join(PathRoot.FullName, item.FileName)); if (value == null) { fi.Delete(); return(Task.CompletedTask); } else { return(FileLoaderPool.Get(fi).Save(value)); } }
private Task <Package <TValue>?> Load(FileItemValue item) { FileInfo fi = new FileInfo(Path.Join(PathRoot.FullName, item.FileName)); return(FileLoaderPool.Get(fi).GetData()); }