static bool DoEnablePaste(ISolutionFolderNode container, IDataObject dataObject) { if (dataObject == null) { return(false); } if (dataObject.GetDataPresent(typeof(ISolutionFolder).ToString())) { string guid = dataObject.GetData(typeof(ISolutionFolder).ToString()).ToString(); ISolutionFolder solutionFolder = container.Solution.GetSolutionFolder(guid); if (solutionFolder == null || solutionFolder == container) { return(false); } if (solutionFolder is ISolutionFolderContainer) { return(solutionFolder.Parent != container && !((ISolutionFolderContainer)solutionFolder).IsAncestorOf(container.Folder)); } else { return(solutionFolder.Parent != container); } } return(false); }
public void WriteSolutionItem(ISolutionItem item) { ISolutionFolder folder = item as ISolutionFolder; IProject project = item as IProject; if (folder != null) { WriteProjectHeader(ProjectTypeGuids.SolutionFolder, folder.Name, folder.Name, folder.IdGuid); // File items are represented as nodes in the tree, but they're actually // saved as properties on their containing folder. SolutionSection section = new SolutionSection("SolutionItems", "preProject"); foreach (var file in folder.Items.OfType <ISolutionFileItem>()) { string location = FileUtility.GetRelativePath(basePath, file.FileName); section.Add(location, location); } WriteProjectSection(section); writer.WriteLine("EndProject"); } else if (project != null) { string location = FileUtility.GetRelativePath(basePath, project.FileName); WriteProjectHeader(project.TypeGuid, project.Name, location, project.IdGuid); foreach (var section in project.ProjectSections) { WriteProjectSection(section); } writer.WriteLine("EndProject"); } }
public virtual void AddFolder(ISolutionFolder folder) { if (string.IsNullOrEmpty(folder.IdGuid)) { folder.IdGuid = Guid.NewGuid().ToString().ToUpperInvariant(); } bool isNew = false; if (folder.Parent != null) { folder.Parent.RemoveFolder(folder); } else { // this is a new project/solution folder isNew = true; } if (isNew) { this.ParentSolution.BeforeAddFolderToSolution(folder); } folder.Parent = this; Folders.Add(folder); if (isNew) { this.ParentSolution.AfterAddFolderToSolution(folder); } }
public void FireSolutionFolderRemoved(ISolutionFolder solutionFolder) { if (SolutionFolderRemoved != null) { SolutionFolderRemoved(this, new SolutionFolderEventArgs(solutionFolder)); } }
/// <summary> /// Create, if necessary, the solution folder for the Blackboard /// Adds an empty Blackboard data file when the folder is created /// </summary> /// <param name="solution">The current VS Solution abstraction from import</param> /// <returns>Path to Solution</returns> private string ProcessSolutionFolder(ISolution solution) { ISolutionFolder blackboardFolder = null; bool solutionFolderExists = false; foreach (var item in solution.Items) { if (item.Name == solutionFolderName) { solutionFolderExists = true; blackboardFolder = item as ISolutionFolder; break; } } if (!solutionFolderExists) { blackboardFolder = solution.CreateSolutionFolder(solutionFolderName); blackboardFolder.AddContent(emptyDictionary, solution.Name + defaultBlackboardFileNameBase, false, false); } else { // // Ok, the solution folder exists, let's see if our file exists // string bbFileName = Path.Combine(Path.GetDirectoryName(solution.PhysicalPath), solution.Name + defaultBlackboardFileNameBase); if (!File.Exists(bbFileName)) { blackboardFolder.AddContent(emptyDictionary, solution.Name + defaultBlackboardFileNameBase, false, false); } } return(Path.Combine(Path.GetDirectoryName(solution.PhysicalPath), solution.Name + defaultBlackboardFileNameBase)); }
public WelcomePageImpl(ISolutionFolder solutionFolder, IDefaultDocumentPolicy defaultDocumentPolicy, IItemOperations itemOperations, IWebServer server) { _solutionFolder = solutionFolder; _itemOperations = itemOperations; _defaultDocumentPolicy = defaultDocumentPolicy; _server = server; }
internal static string GetInitialDirectorySuggestion(ISolutionFolder solutionFolder) { // Detect the correct folder to place the new project in: int projectCount = 0; string initialDirectory = null; foreach (ISolutionItem folderEntry in solutionFolder.Items) { IProject project = folderEntry as IProject; if (project != null) { if (projectCount == 0) initialDirectory = project.Directory; else initialDirectory = FileUtility.GetCommonBaseDirectory(initialDirectory, project.Directory); projectCount++; } } if (initialDirectory != null) { if (projectCount == 1) { return FileUtility.GetAbsolutePath(initialDirectory, ".."); } else { return initialDirectory; } } else { return solutionFolder.ParentSolution.Directory; } }
public static void DoPaste(ISolutionFolderNode folderNode) { if (!DoEnablePaste(folderNode)) { LoggingService.Warn("SolutionFolderNode.DoPaste: Pasting was not enabled."); return; } ExtTreeNode folderTreeNode = (ExtTreeNode)folderNode; IDataObject dataObject = ClipboardWrapper.GetDataObject(); if (dataObject.GetDataPresent(typeof(ISolutionFolder).ToString())) { string guid = dataObject.GetData(typeof(ISolutionFolder).ToString()).ToString(); ISolutionFolder solutionFolder = folderNode.Solution.GetSolutionFolder(guid); if (solutionFolder != null) { folderNode.Container.AddFolder(solutionFolder); ExtTreeView treeView = (ExtTreeView)folderTreeNode.TreeView; foreach (ExtTreeNode node in treeView.CutNodes) { ExtTreeNode oldParent = node.Parent as ExtTreeNode; node.Remove(); node.AddTo(folderTreeNode); if (oldParent != null) { oldParent.Refresh(); } } ProjectService.SaveSolution(); } } folderTreeNode.Expand(); }
static bool DoEnablePaste(ISolutionFolder container, System.Windows.IDataObject dataObject) { if (dataObject == null) { return(false); } if (dataObject.GetDataPresent(typeof(ISolutionItem).ToString())) { Guid guid = Guid.Parse(dataObject.GetData(typeof(ISolutionItem).ToString()).ToString()); ISolutionItem solutionItem = container.ParentSolution.GetItemByGuid(guid); if (solutionItem == null || solutionItem == container) { return(false); } if (solutionItem is ISolutionFolder) { return(solutionItem.ParentFolder != container && !((ISolutionFolder)solutionItem).IsAncestorOf(container)); } else { return(solutionItem.ParentFolder != container); } } return(false); }
public virtual void AddFolder(string folderDirectory) { if (folderDirectory == null) { throw new ArgumentNullException(nameof(folderDirectory)); } var solutionDirectory = SolutionDirectory; if (!folderDirectory.StartsWith(solutionDirectory)) { throw new ArgumentOutOfRangeException(nameof(folderDirectory), "Required to be in solution directory - " + solutionDirectory); } var subPath = folderDirectory.Substring(solutionDirectory.Length); var subDirectories = subPath.Split(Path.DirectorySeparatorChar).Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); ISolutionFolder carryProject = null; foreach (var subFolder in subDirectories) { if (carryProject == null) { carryProject = AddSolutionFolder(subFolder); } else { carryProject = carryProject.AddSubFolder(subFolder); } } carryProject.CopyFilesIntoSolutionFolder(folderDirectory); }
public virtual void AddFolder(ISolutionFolder folder) { if (folder.Parent != null) { folder.Parent.RemoveFolder(folder); } folder.Parent = this; Folders.Add(folder); }
protected virtual ISolutionItem CreateSolutionItem(ISolutionFolder parentFolder, IItemPath path, IItemProperties properties) { Assert.ValidateReference(parentFolder); Assert.ValidateReference(path); Assert.ValidateReference(properties); return(new SolutionItem(path, parentFolder, properties)); }
protected SolutionTreeNode(ISolutionFolder parent, ITreeNodePath path, ITreeNodeProperties properties) { this.Parent = parent; this.Path = path; this.Properties = properties; UpdateName(); InitIsDirty(); }
public void Initialize() { this.guidanceManager = VsIdeTestHostContext.ServiceProvider.GetService<IGuidanceManager>(); this.guidanceManager.ActiveGuidanceExtension = null; this.launchService = VsIdeTestHostContext.ServiceProvider.GetService<IShortcutLaunchService>(); this.solution = VsIdeTestHostContext.ServiceProvider.GetService<ISolution>(); this.solution.Open(this.PathTo(@"Runtime.IntegrationTests.Content\Shortcuts\Shortcuts.sln")); this.solutionItemsFolder = this.solution.SolutionFolders.Single(sf => sf.Name == NuPattern.VisualStudio.Solution.SolutionExtensions.SolutionItemsFolderName); }
public void Initialize() { this.guidanceManager = VsIdeTestHostContext.ServiceProvider.GetService <IGuidanceManager>(); this.guidanceManager.ActiveGuidanceExtension = null; this.launchService = VsIdeTestHostContext.ServiceProvider.GetService <IShortcutLaunchService>(); this.solution = VsIdeTestHostContext.ServiceProvider.GetService <ISolution>(); this.solution.Open(this.PathTo(@"Runtime.IntegrationTests.Content\Shortcuts\Shortcuts.sln")); this.solutionItemsFolder = this.solution.SolutionFolders.Single(sf => sf.Name == NuPattern.VisualStudio.Solution.SolutionExtensions.SolutionItemsFolderName); }
public NewProjectDialogViewModel(ISolutionFolder solutionFolder) : this() { _solutionFolder = solutionFolder; if (_solutionFolder != null) { location = _solutionFolder.Solution.CurrentDirectory; } }
protected void AddExpandedFolder(ISolutionFolder folder) { Assert.ValidateReference(folder); if (!ExpandedFolderList.Contains(folder)) { ExpandedFolderList.Add(folder); } }
/// <summary> /// Initializes a new instance of the <see cref="SolutionFolder"/> class. /// </summary> /// <param name="parent">The parent folder path.</param> /// <param name="path">The folder path.</param> /// <param name="properties">The folder properties.</param> public SolutionFolder(ISolutionFolder parent, IFolderPath path, IFolderProperties properties) : base(parent, path, properties) { if (parent == null) { return; } ChildrenInternal = new SolutionTreeNodeCollection(this, parent.NodeComparer); }
public MoveOperation(ISolutionRoot root, ITreeNodePath path, ISolutionFolder oldParent, ISolutionFolder newParent) : base(root) { Assert.ValidateReference(path); Assert.ValidateReference(oldParent); Assert.ValidateReference(newParent); this.Path = path; this.OldParent = oldParent; this.NewParent = newParent; }
internal static void MoveItem(ISolutionItem solutionItem, ISolutionFolder folder) { // Use a batch update to move the item without causing projects // be removed from the solution (and thus disposed). using (solutionItem.ParentFolder.Items.BatchUpdate()) { using (folder.Items.BatchUpdate()) { solutionItem.ParentFolder.Items.Remove(solutionItem); folder.Items.Add(solutionItem); } } }
public override void Redo() { Add(PathTable); base.Redo(); ISolutionFolder ParentFolder = Root.FindTreeNode(DestinationFolderPath) as ISolutionFolder; Assert.ValidateReference(ParentFolder); AddExpandedFolder(ParentFolder); }
private static ISolutionFolder CreateFolderPath(ISolutionFolder rootFolder, string folderPath) { var paths = folderPath.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); foreach (var path in paths) { rootFolder = rootFolder.CreateSolutionFolder(path); } return(rootFolder); }
internal static void SetParentInternal(this ISolutionItem item, ISolutionFolder parent) { if (item.Parent != null) { item.Parent.Items.Remove(item); } item.Parent = parent; parent?.Items.InsertSorted(item); }
public virtual void RemoveFolder(ISolutionFolder folder) { for (int i = 0; i < Folders.Count; ++i) { if (folder.IdGuid == Folders[i].IdGuid) { Folders.RemoveAt(i); break; } } }
/// <summary> /// Adds a folder to the list. /// </summary> /// <param name="folder">The new folder.</param> protected void AddExpandedFolder(ISolutionFolder folder) { if (folder == null) { throw new ArgumentNullException(nameof(folder)); } if (!ExpandedFolderList.Contains(folder)) { ExpandedFolderList.Add(folder); } }
private string BuildAndEnsureDirectoryStructure(ISolutionFolder solutionFolder) { var parentPath = System.IO.Path.HasExtension(Parent.PhysicalPath) ? System.IO.Path.GetDirectoryName(Parent.PhysicalPath) : Parent.PhysicalPath; var path = System.IO.Path.Combine(parentPath, this.Name); if (!Directory.Exists(path)) Directory.CreateDirectory(path); return path; }
/// <summary> /// Creates a URI for the given solution folder. /// </summary> /// <remarks>solution://root/SolutionFolderPath</remarks> private Uri CreateSolutionFolderUri(ISolutionFolder solutionFolder) { Guard.NotNull(() => solutionFolder, solutionFolder); // Use full solution path format var builder = new StringBuilder() .Append(this.UriScheme) .Append(Uri.SchemeDelimiter) .Append(RootPrefix) .Append(MakeUriPath(solutionFolder.GetLogicalPath())); return(new Uri(builder.ToString())); }
static void HandleRemovedSolutionFolder(ISolutionFolder folder) { if (folder is IProject) { OpenSolution.RemoveProjectConfigurations(folder.IdGuid); ParserService.RemoveProjectContentForRemovedProject((IProject)folder); } if (folder is ISolutionFolderContainer) { // recurse into child folders that were also removed ((ISolutionFolderContainer)folder).Folders.ForEach(HandleRemovedSolutionFolder); } }
public override void Run() { AbstractProjectBrowserTreeNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedNode; ISolutionFolderNode solutionFolderNode = node as ISolutionFolderNode; if (node != null) { ISolutionFolder newSolutionFolder = solutionFolderNode.Folder.CreateFolder(ResourceService.GetString("ProjectComponent.NewFolderString")); solutionFolderNode.Solution.Save(); SolutionFolderNode newSolutionFolderNode = new SolutionFolderNode(newSolutionFolder); newSolutionFolderNode.InsertSorted(node); ProjectBrowserPad.Instance.StartLabelEdit(newSolutionFolderNode); } }
public bool IsAncestorOf(ISolutionFolder folder) { object curParent = folder; while (curParent != null && curParent is ISolutionFolder) { ISolutionFolder curFolder = (ISolutionFolder)curParent; if (curFolder == this) { return(true); } curParent = curFolder.Parent; } return(false); }
public static void Delete(this ISolutionFolder folder) { Guard.NotNull(() => folder, folder); var project = folder.As <EnvDTE.Project>(); if (project != null) { var solutionFolder = project.Object as EnvDTE80.SolutionFolder; if (solutionFolder != null) { project.Delete(); } } }
public async void ShowNewProjectWpfDialog(ISolutionFolder solutionFolder, IEnumerable <TemplateCategory> templates) { #if DEBUG SD.Templates.UpdateTemplates(); #endif ICSharpCode.SharpDevelop.Services.Gui.Dialogs.Wpf.NewProjectDialog npdlg = new ICSharpCode.SharpDevelop.Services.Gui.Dialogs.Wpf.NewProjectDialog(); ICSharpCode.SharpDevelop.Services.Gui.Dialogs.Wpf.NewProjectDialogViewModel npdlgViewModel = new ICSharpCode.SharpDevelop.Services.Gui.Dialogs.Wpf.NewProjectDialogViewModel( templates ?? SD.Templates.TemplateCategories, solutionFolder == null, npdlg); npdlg.SetDataContext(npdlgViewModel); var result = await(SD.Workbench as Window).ShowDialog(npdlg, ClosingEventHandler); }
protected void SolutionFolderRemoved(ISolutionFolder solutionFolder) { IProject project = solutionFolder as IProject; if (project != null) { treeView.RemoveProject(project); } if (solutionFolder is ISolutionFolderContainer) { // recurse into child folders that were also removed ((ISolutionFolderContainer)solutionFolder).Folders.ForEach(SolutionFolderRemoved); } }
private void ChangeParent(ISolutionFolder oldParent, ISolutionFolder newParent) { ISolutionTreeNode?Node = Root.FindTreeNode(Path); if (Node != null) { ISolutionTreeNodeCollection OldChildrenCollection = (ISolutionTreeNodeCollection)oldParent.Children; OldChildrenCollection.Remove(Node); ISolutionTreeNodeCollection NewChildrenCollection = (ISolutionTreeNodeCollection)newParent.Children; NewChildrenCollection.Add(Node); NewChildrenCollection.Sort(); } }
internal bool AddContents(ISolutionFolder parentFolder, ProjectTemplateResult templateResult, string defaultLanguage) { // Create sub projects foreach (SolutionFolderDescriptor folderDescriptor in solutionFoldersDescriptors) { ISolutionFolder folder = parentFolder.CreateFolder(folderDescriptor.name); if (!folderDescriptor.AddContents(folder, templateResult, defaultLanguage)) return false; } foreach (ProjectDescriptor projectDescriptor in projectDescriptors) { IProject newProject = projectDescriptor.CreateProject(templateResult, defaultLanguage); if (newProject == null) return false; parentFolder.Items.Add(newProject); } return true; }
public SolutionFolderNode(ISolutionFolder folder) { sortOrder = 0; canLabelEdit = true; ContextmenuAddinTreePath = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/SolutionFolderNode"; this.solution = folder.ParentSolution; this.folder = folder; this.Tag = folder; Text = folder.Name; autoClearNodes = false; OpenedImage = "ProjectBrowser.SolutionFolder.Open"; ClosedImage = "ProjectBrowser.SolutionFolder.Closed"; Initialize(); }
public ProjectTemplateResult ShowNewProjectDialog(ISolutionFolder solutionFolder, IEnumerable<TemplateCategory> templates) { #if DEBUG SD.Templates.UpdateTemplates(); #endif using (NewProjectDialog npdlg = new NewProjectDialog(templates ?? SD.Templates.TemplateCategories, createNewSolution: solutionFolder == null)) { npdlg.SolutionFolder = solutionFolder; if (solutionFolder != null) { npdlg.InitialProjectLocationDirectory = AddNewProjectToSolution.GetInitialDirectorySuggestion(solutionFolder); } // show the dialog to request project type and name if (npdlg.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) { return npdlg.result; } else { return null; } } }
internal bool AddContents(ISolutionFolder parentFolder, ProjectTemplateResult templateResult, string defaultLanguage) { return mainFolder.AddContents(parentFolder, templateResult, defaultLanguage); }
public void CallSolutionFolderRemoved(ISolutionFolder folder) { base.SolutionFolderRemoved(folder); }
static bool DoEnablePaste(ISolutionFolder container, System.Windows.IDataObject dataObject) { if (dataObject == null) { return false; } if (dataObject.GetDataPresent(typeof(ISolutionItem).ToString())) { Guid guid = Guid.Parse(dataObject.GetData(typeof(ISolutionItem).ToString()).ToString()); ISolutionItem solutionItem = container.ParentSolution.GetItemByGuid(guid); if (solutionItem == null || solutionItem == container) return false; if (solutionItem is ISolutionFolder) { return solutionItem.ParentFolder != container && !((ISolutionFolder)solutionItem).IsAncestorOf(container); } else { return solutionItem.ParentFolder != container; } } return false; }
//Show prompt, create files from template, create project, execute command, save project public bool CreateProject(ProjectTemplateResult templateResults, string defaultLanguage, ISolutionFolder target) { var projectCreateOptions = templateResults.Options; var parentSolution = templateResults.Options.Solution; IProject project = null; bool success = false; try { string language = string.IsNullOrEmpty(languageName) ? defaultLanguage : languageName; ProjectBindingDescriptor descriptor = SD.ProjectService.ProjectBindings.FirstOrDefault(b => b.Language == language); IProjectBinding languageinfo = (descriptor != null) ? descriptor.Binding : null; if (languageinfo == null) { MessageService.ShowError( StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.CantCreateProjectWithTypeError}", new StringTagPair("type", language))); return false; } DirectoryName projectBasePath = projectCreateOptions.ProjectBasePath; string newProjectName = StringParser.Parse(name, new StringTagPair("ProjectName", projectCreateOptions.ProjectName)); Directory.CreateDirectory(projectBasePath); FileName projectLocation = projectBasePath.CombineFile(newProjectName + descriptor.ProjectFileExtension); ProjectCreateInformation info = new ProjectCreateInformation(parentSolution, projectLocation); info.TargetFramework = projectCreateOptions.TargetFramework; StringBuilder standardNamespace = new StringBuilder(); // filter 'illegal' chars from standard namespace if (!string.IsNullOrEmpty(newProjectName)) { char ch = '.'; for (int i = 0; i < newProjectName.Length; ++i) { if (ch == '.') { // at beginning or after '.', only a letter or '_' is allowed ch = newProjectName[i]; if (!Char.IsLetter(ch)) { standardNamespace.Append('_'); } else { standardNamespace.Append(ch); } } else { ch = newProjectName[i]; // can only contain letters, digits or '_' if (!Char.IsLetterOrDigit(ch) && ch != '.') { standardNamespace.Append('_'); } else { standardNamespace.Append(ch); } } } } info.TypeGuid = descriptor.TypeGuid; info.RootNamespace = standardNamespace.ToString(); info.ProjectName = newProjectName; if (!string.IsNullOrEmpty(defaultPlatform)) info.ActiveProjectConfiguration = new ConfigurationAndPlatform("Debug", defaultPlatform); RunPreCreateActions(info); StringParserPropertyContainer.FileCreation["StandardNamespace"] = info.RootNamespace; if (File.Exists(projectLocation)) { if (!MessageService.AskQuestion( StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteProjectQuestion}", new StringTagPair("projectLocation", projectLocation)), "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion.InfoName}")) { return false; //The user doesnt want to overwrite the project... } } //Show prompt if any of the files exist StringBuilder existingFileNames = new StringBuilder(); foreach (FileDescriptionTemplate file in files) { string fileName = Path.Combine(projectBasePath, StringParser.Parse(file.Name, new StringTagPair("ProjectName", info.ProjectName))); if (File.Exists(fileName)) { if (existingFileNames.Length > 0) existingFileNames.Append(", "); existingFileNames.Append(Path.GetFileName(fileName)); } } bool overwriteFiles = true; if (existingFileNames.Length > 0) { if (!MessageService.AskQuestion( StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion}", new StringTagPair("fileNames", existingFileNames.ToString())), "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion.InfoName}")) { overwriteFiles = false; } } #region Copy files to target directory foreach (FileDescriptionTemplate file in files) { string fileName = Path.Combine(projectBasePath, StringParser.Parse(file.Name, new StringTagPair("ProjectName", info.ProjectName))); if (File.Exists(fileName) && !overwriteFiles) { continue; } try { if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } if (!String.IsNullOrEmpty(file.BinaryFileName)) { // Binary content File.Copy(file.BinaryFileName, fileName, true); } else { // Textual content StreamWriter sr = new StreamWriter(File.Create(fileName), SD.FileService.DefaultFileEncoding); string fileContent = StringParser.Parse(file.Content, new StringTagPair("ProjectName", projectCreateOptions.ProjectName), new StringTagPair("SolutionName", projectCreateOptions.SolutionName), new StringTagPair("FileName", fileName)); fileContent = StringParser.Parse(fileContent); if (SD.EditorControlService.GlobalOptions.IndentationString != "\t") { fileContent = fileContent.Replace("\t", SD.EditorControlService.GlobalOptions.IndentationString); } sr.Write(fileContent); sr.Close(); } } catch (Exception ex) { MessageService.ShowException(ex, "Exception writing " + fileName); } } #endregion #region Create Project try { info.InitializeTypeSystem = false; project = languageinfo.CreateProject(info); } catch (ProjectLoadException ex) { MessageService.ShowError(ex.Message); return false; } #endregion #region Create Project Items, Imports and Files // Add Project items if (!project.Items.IsReadOnly) { foreach (ProjectItem projectItem in projectItems) { ProjectItem newProjectItem = new UnknownProjectItem( project, StringParser.Parse(projectItem.ItemType.ItemName), StringParser.Parse(projectItem.Include, new StringTagPair("ProjectName", projectCreateOptions.ProjectName), new StringTagPair("SolutionName", projectCreateOptions.SolutionName)) ); foreach (string metadataName in projectItem.MetadataNames) { string metadataValue = projectItem.GetMetadata(metadataName); // if the input contains any special MSBuild sequences, don't escape the value // we want to escape only when the special characters are introduced by the StringParser.Parse replacement if (metadataValue.Contains("$(") || metadataValue.Contains("%")) newProjectItem.SetMetadata(StringParser.Parse(metadataName), StringParser.Parse(metadataValue)); else newProjectItem.SetEvaluatedMetadata(StringParser.Parse(metadataName), StringParser.Parse(metadataValue)); } project.Items.Add(newProjectItem); } } // Add properties from <PropertyGroup> // This must be done before adding <Imports>, because the import path can refer to properties. if (projectProperties.Count > 0) { if (!(project is MSBuildBasedProject)) throw new Exception("<PropertyGroup> may be only used in project templates for MSBuildBasedProjects"); foreach (ProjectProperty p in projectProperties) { ((MSBuildBasedProject)project).SetProperty( StringParser.Parse(p.Configuration), StringParser.Parse(p.Platform), StringParser.Parse(p.Name), StringParser.Parse(p.Value), p.Location, p.ValueIsLiteral ); } } // Add Imports if (clearExistingImports || projectImports.Count > 0) { MSBuildBasedProject msbuildProject = project as MSBuildBasedProject; if (msbuildProject == null) throw new Exception("<Imports> may be only used in project templates for MSBuildBasedProjects"); try { msbuildProject.PerformUpdateOnProjectFile( delegate { var projectFile = msbuildProject.MSBuildProjectFile; if (clearExistingImports) { foreach (var import in projectFile.Imports.ToArray()) projectFile.RemoveChild(import); } foreach (Import projectImport in projectImports) { projectFile.AddImport(projectImport.Key).Condition = projectImport.Value; } }); } catch (InvalidProjectFileException ex) { string message; if (string.IsNullOrEmpty(importsFailureMessage)) { message = "Error creating project:\n" + ex.Message; } else { message = importsFailureMessage + "\n\n" + ex.Message; } throw new ProjectLoadException(message, ex); } } // Add Files if (!project.Items.IsReadOnly) { foreach (FileDescriptionTemplate file in files) { string fileName = Path.Combine(projectBasePath, StringParser.Parse(file.Name, new StringTagPair("ProjectName", projectCreateOptions.ProjectName))); FileProjectItem projectFile = new FileProjectItem(project, project.GetDefaultItemType(fileName)); projectFile.Include = FileUtility.GetRelativePath(project.Directory, fileName); file.SetProjectItemProperties(projectFile); project.Items.Add(projectFile); } } #endregion RunCreateActions(project); project.ProjectCreationComplete(); // Save project project.Save(); // HACK : close and reload var fn = project.FileName; project.Dispose(); ProjectLoadInformation loadInfo = new ProjectLoadInformation(parentSolution, fn, fn.GetFileNameWithoutExtension()); project = SD.ProjectService.LoadProject(loadInfo); target.Items.Add(project); project.ProjectLoaded(); SD.GetRequiredService<IProjectServiceRaiseEvents>().RaiseProjectCreated(new ProjectEventArgs(project)); templateResults.NewProjects.Add(project); success = true; return true; } finally { if (project != null && !success) project.Dispose(); } }
protected void SolutionFolderRemoved(ISolutionFolder solutionFolder) { treeView.RemoveSolutionFolder(solutionFolder); }
static void HandleRemovedSolutionFolder(ISolutionFolder folder) { IProject project = folder as IProject; if (project != null) { OpenSolution.RemoveProjectConfigurations(project.IdGuid); ParserService.RemoveProjectContentForRemovedProject(project); project.Dispose(); } if (folder is ISolutionFolderContainer) { // recurse into child folders that were also removed ((ISolutionFolderContainer)folder).Folders.ForEach(HandleRemovedSolutionFolder); } }
public SolutionFolderEventArgs(ISolutionFolder solutionFolder) { this.solutionFolder = solutionFolder; }
public SolutionFolderRemoveVisitor(ISolutionFolder folder) { this.folder = folder; }
internal void AfterAddFolderToSolution(ISolutionFolder folder) { IProject project = folder as IProject; if (project != null && !isLoading) { FixSolutionConfiguration(new[] { project }); } }
internal void AfterAddFolderToSolution(ISolutionFolder folder) { IProject project = folder as IProject; if (project != null && !isLoading) { var projectConfigurations = project.ConfigurationNames; var solutionConfigurations = this.GetConfigurationNames(); var projectPlatforms = project.PlatformNames; var solutionPlatforms = this.GetPlatformNames(); foreach (string config in solutionConfigurations) { string projectConfig = config; if (!projectConfigurations.Contains(projectConfig)) projectConfig = projectConfigurations.FirstOrDefault() ?? "Debug"; foreach (string platform in solutionPlatforms) { string projectPlatform = FixPlatformNameForProject(platform); if (!projectPlatforms.Contains(projectPlatform)) projectPlatform = projectPlatforms.FirstOrDefault() ?? "AnyCPU"; CreateMatchingItem(config, platform, project, projectConfig + "|" + FixPlatformNameForSolution(projectPlatform)); } } } }
public void RemoveSolutionFolder(ISolutionFolder solutionFolder) { IProject project = solutionFolder as IProject; if (project != null) { RemoveProject(project); } ISolutionFolderContainer solutionFolderContainer = solutionFolder as ISolutionFolderContainer; if (solutionFolderContainer != null) { foreach (ISolutionFolder subSolutionFolder in solutionFolderContainer.Folders) { RemoveSolutionFolder(subSolutionFolder); } } }
public bool IsAncestorOf(ISolutionFolder folder) { object curParent = folder; while (curParent != null && curParent is ISolutionFolder) { ISolutionFolder curFolder = (ISolutionFolder)curParent; if (curFolder == this) { return true; } curParent = curFolder.Parent; } return false; }
internal void BeforeAddFolderToSolution(ISolutionFolder folder) { IProject project = folder as IProject; if (project != null && !isLoading) { // HACK: don't deal with configurations during loading if (this.GetConfigurationNames().Count == 0) { foreach (string config in project.ConfigurationNames) { foreach (string platform in project.PlatformNames) AddSolutionConfigurationPlatform(config, FixPlatformNameForSolution(platform), null, false, false); } } } }
public override void AddFolder(ISolutionFolder folder) { base.AddFolder(folder); guidDictionary[folder.IdGuid] = folder; }