public void Load(string fileName, NiProjectCreateMode createMode) { this.SetPropertyEx(NiHierarchyProperty.Name, Path.GetFileNameWithoutExtension(fileName)); // Load the project from the file system. LoadDirectory(this, Path.GetDirectoryName(fileName)); // Associate a NiTextLines with the project to store the project // file in. object obj; ErrorUtil.ThrowOnFailure(((INiLocalRegistry)GetService(typeof(INiLocalRegistry))).CreateInstance( new Guid(NiConstants.TextLines), this, out obj )); var textLines = (INiTextLines)obj; // If we're creating a new project, create a file on disk and load that. if (createMode != NiProjectCreateMode.Open) new XDocument(new XElement((XNamespace)TPResources.ProjectNs + "testProject")).Save(fileName); ErrorUtil.ThrowOnFailure(textLines.LoadDocData(fileName)); ErrorUtil.ThrowOnFailure(((INiRunningDocumentTable)GetService(typeof(INiRunningDocumentTable))).Register( fileName, this, textLines, out _rdtCookie )); }
private INiProject LoadProject(string fileName, NiProjectCreateMode createMode) { var project = new Project(); project.SetSite(this); project.Load(fileName, createMode); return project; }
private INiProject LoadProject(string fileName, NiProjectCreateMode createMode) { var project = new Project(); project.SetSite(this); project.Load(fileName, createMode); return(project); }
public override HResult CreateProject(string fileName, NiProjectCreateMode createMode, out INiProject project) { project = null; try { project = LoadProject(fileName, createMode); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public override HResult CreateProject(string fileName, NiProjectCreateMode createMode, out INiProject project) { project = null; try { project = LoadProject(fileName, createMode); return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public void Load(string fileName, NiProjectCreateMode createMode) { this.SetPropertyEx(NiHierarchyProperty.Name, Path.GetFileNameWithoutExtension(fileName)); // Load the project from the file system. LoadDirectory(this, Path.GetDirectoryName(fileName)); // Associate a NiTextLines with the project to store the project // file in. object obj; ErrorUtil.ThrowOnFailure(((INiLocalRegistry)GetService(typeof(INiLocalRegistry))).CreateInstance( new Guid(NiConstants.TextLines), this, out obj )); var textLines = (INiTextLines)obj; // If we're creating a new project, create a file on disk and load that. if (createMode != NiProjectCreateMode.Open) { new XDocument(new XElement((XNamespace)TPResources.ProjectNs + "testProject")).Save(fileName); } ErrorUtil.ThrowOnFailure(textLines.LoadDocData(fileName)); ErrorUtil.ThrowOnFailure(((INiRunningDocumentTable)GetService(typeof(INiRunningDocumentTable))).Register( fileName, this, textLines, out _rdtCookie )); }
private HResult OpenProject(string fileName, NiProjectCreateMode mode) { try { if (fileName == null) { throw new ArgumentNullException("fileName"); } // Find the associated factory. INiProjectFactory factory = null; string extension = Path.GetExtension(fileName); if (extension != null) { Debug.Assert(extension[0] == '.' && extension.Length > 1); factory = FindProjectFactory(extension.Substring(1)); } if (factory == null) { throw new ArgumentException(NeutralResources.CannotFindProjectFactory, "fileName"); } // Close the existing project. if (ActiveProject != null) { var activeProject = ActiveProject; ActiveProject = null; activeProject.Close(); } // Create and load the new project. INiProject project; var result = factory.CreateProject( fileName, mode, out project ); if (ErrorUtil.Failure(result)) { return(result); } project.SetPropertyEx(NiHierarchyProperty.OwnerType, factory.GetType().GUID); ActiveProject = project; return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public abstract HResult CreateProject(string fileName, NiProjectCreateMode createMode, out INiProject project);
private HResult OpenProject(string fileName, NiProjectCreateMode mode) { try { if (fileName == null) throw new ArgumentNullException("fileName"); // Find the associated factory. INiProjectFactory factory = null; string extension = Path.GetExtension(fileName); if (extension != null) { Debug.Assert(extension[0] == '.' && extension.Length > 1); factory = FindProjectFactory(extension.Substring(1)); } if (factory == null) throw new ArgumentException(NeutralResources.CannotFindProjectFactory, "fileName"); // Close the existing project. if (ActiveProject != null) { var activeProject = ActiveProject; ActiveProject = null; activeProject.Close(); } // Create and load the new project. INiProject project; var result = factory.CreateProject( fileName, mode, out project ); if (ErrorUtil.Failure(result)) return result; project.SetPropertyEx(NiHierarchyProperty.OwnerType, factory.GetType().GUID); ActiveProject = project; return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }