/// <summary> /// Creates new verion of the project from the existing version <param name="branchedVersion" />. /// The created version is fully integrated into versioning system /// (dictionaries <see cref="Exolutio.Model.Project" />.<see cref="Exolutio.Model.Project.ProjectVersions" /> and version links /// among <see cref="IVersionedItem"/>s). /// </summary> /// <param name="branchedVersion">Existing version in the project</param> /// <param name="newVersion">New version marker. Created, but "emtpy", must not be member of Project.Versions collection</param> public ProjectVersion BranchProject(ProjectVersion branchedVersion, Version newVersion) { branching = true; newVersion.BranchedFrom = branchedVersion.Version; Versions.Add(newVersion); ProjectVersion newProjectVersion = new ProjectVersion(Project); newProjectVersion.Version = newVersion; ElementCopiesMap elementCopiesMap = new ElementCopiesMap(Project, Project); IEnumerable <ExolutioObject> allModelItems = ModelIterator.GetAllModelItems(branchedVersion); List <ExolutioObject> exolutioObjects = allModelItems.ToList(); elementCopiesMap.PrepareGuids(exolutioObjects); elementCopiesMap.PrepareGuid(branchedVersion); branchedVersion.FillCopy(newProjectVersion, newProjectVersion, elementCopiesMap); Project.ProjectVersions.Add(newProjectVersion); foreach (KeyValuePair <IVersionedItem, IVersionedItem> keyValuePair in elementCopiesMap) { RegisterVersionLink(branchedVersion.Version, newVersion, keyValuePair.Key, keyValuePair.Value); } branching = false; return(newProjectVersion); }
public Project SeparateVersion(ProjectVersion projectVersion, bool keepGuids) { Project separatedProject = new Project(); separatedProject.InitNewEmptyProject(false); ElementCopiesMap elementCopiesMap = new ElementCopiesMap(Project, separatedProject); elementCopiesMap.KeepGuids = keepGuids; IEnumerable <ExolutioObject> allModelItems = ModelIterator.GetAllModelItems(projectVersion); List <ExolutioObject> exolutioObjects = allModelItems.ToList(); elementCopiesMap.PrepareGuids(exolutioObjects); elementCopiesMap.PrepareGuid(projectVersion); projectVersion.FillCopy(separatedProject.SingleVersion, separatedProject.SingleVersion, elementCopiesMap); return(separatedProject); }
public void EmbedVersion(ProjectVersion embededVersion, Version newVersion, Version branchedFrom, bool keepGuids, bool createVersionLinks) { newVersion.BranchedFrom = branchedFrom; Versions.Add(newVersion); ProjectVersion newProjectVersion = new ProjectVersion(Project); newProjectVersion.Version = newVersion; ElementCopiesMap elementCopiesMap = new ElementCopiesMap(embededVersion.Project, Project); elementCopiesMap.KeepGuids = keepGuids; IEnumerable <ExolutioObject> allModelItems = ModelIterator.GetAllModelItems(embededVersion); List <ExolutioObject> exolutioObjects = allModelItems.ToList(); elementCopiesMap.PrepareGuids(exolutioObjects); elementCopiesMap.PrepareGuid(embededVersion); Project.ProjectVersions.Add(newProjectVersion); embededVersion.FillCopy(newProjectVersion, newProjectVersion, elementCopiesMap); if (createVersionLinks) { foreach (KeyValuePair <IVersionedItem, IVersionedItem> kvp in elementCopiesMap) { IVersionedItem fromEmbedded = kvp.Key; IVersionedItem newlyCreated = kvp.Value; ExolutioObject previousObject; if (Project.TryTranslateObject(fromEmbedded.ID, out previousObject) && previousObject is IVersionedItem) { if (Project.mappingDictionary.ContainsKey(previousObject.ID) && Project.mappingDictionary.ContainsKey(newlyCreated.ID)) { RegisterVersionLink(((IVersionedItem)previousObject).Version, newVersion, (IVersionedItem)previousObject, newlyCreated); } } } } }