Exemple #1
0
        public async Task SaveSerializedDataAsync()
        {
            var path       = GetProjectsContentPath(SavePath.Value);
            var rootType   = Root.Value.Type;
            var serializer = rootType.GetMethods()
                             .FirstOrDefault(x => x.GetCustomAttribute <PwSerializerAttribute>() != null);

            if (serializer != null)
            {
                await CustomSerializer.SaveDataAsync(serializer, Root.Value, path);
            }
            else
            {
                await JsonSerializer.SaveDataAsync(Root.Value, path);
            }
        }
Exemple #2
0
        private async Task LoadSerializedDataAsync()
        {
            var path = GetProjectsContentPath(SavePath.Value);

            if (!File.Exists(path))
            {
                return;
            }

            var deserializer = Root.Value.Type.GetMethods()
                               .FirstOrDefault(x => x.GetCustomAttribute <PwDeserializerAttribute>() != null);

            if (deserializer != null)
            {
                await CustomSerializer.LoadDataAsync(deserializer, Root.Value, path);
            }
            else
            {
                await JsonSerializer.LoadDataAsync(Root.Value, path);
            }
        }