示例#1
0
 public static void SaveState <T>(this T vm) where T : CoreViewModel, new()
 {
     Task.Run(async() =>
     {
         await CoreDependencyService.GetService <IFileStore, FileStore>(true)?.SaveAsync <T>(typeof(T).FullName, vm);
     });
 }
示例#2
0
 public static void LoadState <T>(this T vm) where T : CoreViewModel, new()
 {
     Task.Run(async() =>
     {
         var result = await CoreDependencyService.GetService <IFileStore, FileStore>(true)?.GetAsync <T>(typeof(T).FullName);
         if (result.Error == null)
         {
             foreach (var prop in typeof(T).GetProperties())
             {
                 prop.SetValue(vm, prop.GetValue(result.Response));
             }
         }
     });
 }