private void LoadIssuesFromStorageStore() { IEnumerable <int> issuesIds = null; IssueInfo[] issueInfos = null; using (var storage = m_Model.TryOpenStorage(STORAGE_NAME, AccessType_e.Read)) { if (storage != null) { 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 (m_Model.Visible) { ShowIssues?.Invoke(m_IssuesVm); } }
private void LoadFromStorage(IXDocument doc) { var path = SUB_STORAGE_PATH.Split('\\'); using (var storage = doc.TryOpenStorage(path[0], AccessType_e.Read)) { if (storage != null) { using (var subStorage = storage.TryOpenStorage(path[1], false)) { if (subStorage != null) { foreach (var subStreamName in subStorage.GetSubStreamNames()) { using (var str = subStorage.TryOpenStream(subStreamName, false)) { if (str != null) { var buffer = new byte[str.Length]; str.Read(buffer, 0, buffer.Length); var timeStamp = Encoding.UTF8.GetString(buffer); //m_App.ShowMessageBox($"Metadata stamp in {subStreamName} of {doc.Title}: {timeStamp}"); } else { //m_App.ShowMessageBox($"No metadata stamp stream in {doc.Title}"); } } } } } } else { //m_App.ShowMessageBox($"No metadata storage in {doc.Title}"); } } }