private void LoadIssuesFromStorageStore() { IEnumerable <int> issuesIds = null; IssueInfo[] issueInfos = null; using (var storageHandler = Model.Access3rdPartyStorageStore(STORAGE_NAME, false)) { if (storageHandler.Storage != null) { using (var storage = storageHandler.Storage) { using (var issuesStore = storage.TryOpenStorage(ISSUES_SUB_STORAGE_NAME, false)) { if (issuesStore != null) { issuesIds = issuesStore.GetSubStreamNames().Select(n => int.Parse(n)); } } using (var stream = storage.TryOpenStream(ISSUES_SUMMARIES_STREAM_NAME, false)) { if (stream != null) { var ser = new DataContractSerializer(typeof(IssueInfo[])); issueInfos = ser.ReadObject(stream) as IssueInfo[]; } } } } } if (issuesIds == null) { issuesIds = Enumerable.Empty <int>(); } if (issueInfos == null) { issueInfos = new IssueInfo[0]; } if (!issueInfos.Select(i => i.Id).OrderBy(i => i) .SequenceEqual(issuesIds.OrderBy(i => i))) { throw new InvalidOperationException("Issues mismatch"); } m_IssuesVm = new IssuesVM(issueInfos); m_IssuesVm.Modified += OnIssuesModified; m_IssuesVm.LoadIssue += OnLoadIssue; if (Model.Visible) { ShowIssues?.Invoke(m_IssuesVm); } }
private void OnShowIssues(IssuesVM issues) { m_IssuesControl.DataContext = issues; }