Beispiel #1
0
 private static void Reload(SettingModel model)
 {
     if (File.Exists(SettingsPath))
     {
         var tmp = JsonConvert.DeserializeObject <SettingModel>(File.ReadAllText(SettingsPath));
         var mt  = model.GetType();
         foreach (var p in tmp.GetType().GetProperties())
         {
             var dp = mt.GetProperty(p.Name);
             if (dp?.CanWrite ?? false)
             {
                 var d = p.GetValue(tmp);
                 dp.SetValue(model, d, null);
             }
         }
     }
     else
     {
         model.DefaultSettings();
     }
 }