private void LoadInformation() { Manifests.Clear(); try { var manifests = _manifestService.GetManifestNames(); foreach (var manifestName in manifests) { var manifest = _manifestService.GetManifest(manifestName); Manifests.Add(new ManifestViewModel { Name = manifestName, DomainOverride = manifest.OverrideDomain, DomainOverrideChangedCommand = new RelayCommand(param => _manifestService.SetActiveManifestDomain(param != null ? param.ToString() : string.Empty)) }); } var selectedManifestName = _manifestService.GetActiveManifestName(); SelectedManifest = Manifests.FirstOrDefault(m => m.Name == selectedManifestName); } catch (Exception e) { MessageBox.Show(e.Message, "Error Loading Manifest List", MessageBoxButton.OK, MessageBoxImage.Error); } }
//public RelayCommand EditCommand { get; set; } /// <summary> /// いくつかの ItemViewModel オブジェクトを作成し、Items コレクションに追加します。 /// </summary> public void LoadData() { var manifests = IOManager.GetManager().LoadManifests().Reverse().ToList();// as List<ManifestModel>; if (manifests.Count > 0) { for (var i = 0; i < manifests.Count; i++)// m in manifests) { var m = manifests[i]; if (m.Contents.Count == 0) { m.Contents.Add(new ContentModel { Description = "タップすると、目標の編集・小目標の追加ができます。" }); } Manifests.Add(m); } (App.Current as App).SelectedManifestID = Manifests[0].ID; SelectedDone = Manifests[0].IsDone; IOManager.GetManager().LoadSetting(); this.IsDataLoaded = true; Messenger.Default.Send("", Contract.UpdateAgent); } else { Messenger.Default.Send("", Contract.RedirectToInitial); Messenger.Default.Send("", Contract.InitializeFail); } }
public void GetManifests() { JObject m = null; string target = Version; do { if (m != null) { target = (string)m.GetValue("inheritsFrom"); } var dest = Path.Combine(Root, "versions", target); if (!Directory.Exists(dest)) { Directory.CreateDirectory(dest); } string targetPath = Path.Combine(dest, target + ".json"); Program.repo.DownloadFile($"versions/{target}/{target}.json", targetPath); using (StreamReader sr = new StreamReader(targetPath)) { string content = sr.ReadToEnd(); m = JObject.Parse(content); } Manifests.Add(m); }while (m.TryGetValue("inheritsFrom", out JToken _)); IsInherited = Manifests.Count > 1; Manifest = Manifests.Last(); ActualVersion = (string)Manifest.GetValue("id"); for (int i = (Manifests.Count - 2); i >= 0; i--) { Manifest.Merge(Manifests[i], new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Concat }); } }