private async Task LoadConfig() { string json = null; bool ok = ApplicationData.Current.LocalSettings.Values.TryGetValue("config", out object temp); if (ok) { json = temp.ToString(); } if (string.IsNullOrEmpty(json)) { SettingObject setting = SettingObject.GetDefaultSetting(); json = await JsonHelper.JsonSerializeAsync(setting); } var config = await JsonHelper.JsonDeserializeAsync <SettingObject>(json); if (config.General == null) { config.General = new GeneralSetting(); } //UWP string descPath = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Res\\setting.desc.json"); var descConfig = await JsonHelper.JsonDeserializeFromFileAsync <dynamic>(descPath); JsonConfierViewModel = _jcrService.GetVM(JObject.FromObject(config), descConfig); }
public JsonConfierViewModel GetVM(JObject config, JObject descConfig) { var vm = new JsonConfierViewModel { Nodes = ResolveJson(config, descConfig).Nodes }; vm.Nodes[0].Selected = true; return(vm); }
public JsonConfierViewModel GetVM(object config, object descConfig) { if (!(config is JObject json)) { return(null); } var vm = new JsonConfierViewModel { Nodes = ResolveJson(config as JObject, descConfig as JObject).Nodes }; vm.Nodes[0].Selected = true; return(vm); }