예제 #1
0
        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);
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        private Task <Package <TValue>?> Load(FileItemValue item)
        {
            FileInfo fi = new FileInfo(Path.Join(PathRoot.FullName, item.FileName));

            return(FileLoaderPool.Get(fi).GetData());
        }