From 8bcb176c75b4ba4ec19a23c016418be8f91f4e80 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 16 Apr 2006 21:21:49 +0000 Subject: [PATCH] Don't add duplicate references specified in project template (new project instances might come with predefined reference items) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1311 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Gui/Dialogs/NewProjectDialog.cs | 17 ----------------- .../Templates/Project/ProjectDescriptor.cs | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs index 4d9bd437e5..bb0cec3c79 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs @@ -256,23 +256,6 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs return true; } - public void SaveFile(IProject project, string filename, string content, bool showFile) - { - FileProjectItem newItem = new FileProjectItem(project, ItemType.Compile); - newItem.Include = filename; - ProjectService.AddProjectItem(project, newItem); - - StreamWriter sr = File.CreateText(filename); - sr.Write(StringParser.Parse(content, new string[,] { {"PROJECT", ((TextBox)ControlDictionary["nameTextBox"]).Text}, {"FILE", Path.GetFileName(filename)}})); - sr.Close(); - - if (showFile) { - string longfilename = Path.Combine(ProjectSolution, StringParser.Parse(filename, new string[,] { {"PROJECT", ((TextBox)ControlDictionary["nameTextBox"]).Text}})); - - FileService.OpenFile(longfilename); - } - } - public string NewProjectLocation; public string NewCombineLocation; diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs index 11c10418b6..28cfea7103 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs @@ -142,8 +142,19 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates StringParser.Properties["StandardNamespace"] = project.RootNamespace; // Add Project items foreach (ProjectItem projectItem in projectItems) { - projectItem.Project = project; - project.Items.Add(projectItem); + bool itemFound = false; + foreach (ProjectItem existingItem in project.Items) { + if (existingItem.ItemType == projectItem.ItemType + && existingItem.Include == projectItem.Include) + { + itemFound = true; + break; + } + } + if (!itemFound) { + projectItem.Project = project; + project.Items.Add(projectItem); + } } // Add Imports