protected override void LoadProjectStreamCore(ProjectStreamInfo projectStreamInfo) { if (projectStreamInfo.Uri == null) { #if GISEditorUnitTest projectStreamInfo.Uri = new Uri(Path.GetFullPath(@"..\..\..\UnitTestData\tmpProject.tgproj")); #else if (openFileDialog.ShowDialog().GetValueOrDefault()) { string projectFilePath = openFileDialog.FileName; projectStreamInfo.Uri = new Uri(projectFilePath); } else { projectStreamInfo.Uri = null; } #endif } if (ProjectExists(projectStreamInfo.Uri)) { MemoryStream stream = new MemoryStream(File.ReadAllBytes(projectStreamInfo.Uri.LocalPath)); stream.Seek(0, SeekOrigin.Begin); projectStreamInfo.Stream = stream; } }
protected override void SaveProjectStreamCore(ProjectStreamInfo projectStreamInfo) { if (projectStreamInfo.Stream != null && GisEditor.ProjectManager.CanSaveProject(projectStreamInfo)) { byte[] buffer = new byte[projectStreamInfo.Stream.Length]; projectStreamInfo.Stream.Read(buffer, 0, buffer.Length); try { lockObject.EnterWriteLock(); File.WriteAllBytes(projectStreamInfo.Uri.LocalPath, buffer); } catch (Exception ex) { GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); } finally { lockObject.ExitWriteLock(); } } }