Beispiel #1
0
 /// <summary>
 /// Renames the model system within the project
 /// </summary>
 /// <param name="root">The root structure of the model system to rename</param>
 /// <param name="newName">The name to set this model system to.</param>
 /// <param name="error">An error message that describes why this operation has failed.</param>
 /// <returns>True if the model system was renamed, if not the error will describe why not.</returns>
 public bool RenameModelSystem(IModelSystemStructure root, string newName, ref string error)
 {
     lock (EditingSessionsLock)
     {
         var index = Project.ModelSystemStructure.IndexOf(root);
         if (index < 0)
         {
             error = "The model system was not found within the project!";
             return(false);
         }
         // check to see if the model system is being edited, if it is send a command to that session
         var editingSession = EditingSessions.FirstOrDefault(s => s.Session != null && s.Session.IsEditing(root));
         if (editingSession.Session != null)
         {
             editingSession.Session.ModelSystemModel.ChangeModelSystemName(newName, ref error);
         }
         //In any case we need to save this change so everything updates accordingly
         Project.ModelSystemStructure[index].Name = newName;
         Project.Save(ref error);
     }
     return(true);
 }
 /// <summary>
 /// Loads a project if it exists or creates a new project with the given name.
 /// </summary>
 /// <param name="name">The name of the project</param>
 /// <param name="error">AContains an error message in case of failure</param>
 /// <returns>The loaded project</returns>
 public Project LoadOrCreate(string name, ref string error)
 {
     lock (EditingSessionLock)
     {
         Project alreadyLoaded;
         if ((alreadyLoaded = Load(name, ref error)) != null)
         {
             return(alreadyLoaded);
         }
         error = null;
         if (!ValidateProjectName(name, ref error))
         {
             return(null);
         }
         var newProject = new Project(name, Runtime.Configuration);
         if (!newProject.Save(ref error))
         {
             return(null);
         }
         Runtime.Configuration.ProjectRepository.AddProject(newProject);
         return(newProject);
     }
 }