Browse Source

Implemented deleting project items.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/dotnet4@4124 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
7c000c9f6e
  1. 5
      src/Main/Base/Project/Src/Project/Items/ItemType.cs
  2. 40
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

5
src/Main/Base/Project/Src/Project/Items/ItemType.cs

@ -68,9 +68,6 @@ namespace ICSharpCode.SharpDevelop.Project
} }
#region Equals and GetHashCode implementation #region Equals and GetHashCode implementation
// The code in this region is useful if you want to use this structure in collections.
// If you don't need it, you can just remove the region and the ": IEquatable<ItemType>" declaration.
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj is ItemType) if (obj is ItemType)
@ -81,13 +78,11 @@ namespace ICSharpCode.SharpDevelop.Project
public bool Equals(ItemType other) public bool Equals(ItemType other)
{ {
// add comparisions for all members here
return this.itemName == other.itemName; return this.itemName == other.itemName;
} }
public override int GetHashCode() public override int GetHashCode()
{ {
// combine the hash codes of all members here (e.g. with XOR operator ^)
return itemName.GetHashCode(); return itemName.GetHashCode();
} }

40
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -89,15 +89,9 @@ namespace ICSharpCode.SharpDevelop.Project
lock (SyncRoot) { lock (SyncRoot) {
projectFile.ToolsVersion = "4.0"; projectFile.ToolsVersion = "4.0";
userProjectFile.ToolsVersion = "4.0"; userProjectFile.ToolsVersion = "4.0";
Reevaluate();
} }
} }
void Reevaluate()
{
// ?
}
public override void ResolveAssemblyReferences() public override void ResolveAssemblyReferences()
{ {
MSBuildInternals.ResolveAssemblyReferences(this, null); MSBuildInternals.ResolveAssemblyReferences(this, null);
@ -205,7 +199,6 @@ namespace ICSharpCode.SharpDevelop.Project
{ {
lock (SyncRoot) { lock (SyncRoot) {
projectFile.AddImport(importedProjectFile).Condition = condition; projectFile.AddImport(importedProjectFile).Condition = condition;
Reevaluate();
} }
} }
#endregion #endregion
@ -314,6 +307,16 @@ namespace ICSharpCode.SharpDevelop.Project
} }
} }
MSBuild.Project currentlyOpenProject;
void ReconfigureCurrentlyOpenProject()
{
if (currentlyOpenProject != null) {
projectCollection.UnloadProject(currentlyOpenProject);
currentlyOpenProject = null;
}
}
ConfiguredProject OpenCurrentConfiguration() ConfiguredProject OpenCurrentConfiguration()
{ {
return OpenConfiguration(null, null); return OpenConfiguration(null, null);
@ -329,6 +332,15 @@ namespace ICSharpCode.SharpDevelop.Project
configuration = this.ActiveConfiguration; configuration = this.ActiveConfiguration;
if (platform == null) if (platform == null)
platform = this.ActivePlatform; platform = this.ActivePlatform;
bool openCurrentConfiguration = configuration == this.ActiveConfiguration && platform == this.ActivePlatform;
if (currentlyOpenProject != null && openCurrentConfiguration) {
// use currently open project
currentlyOpenProject.ReevaluateIfNecessary();
return new ConfiguredProject(this, currentlyOpenProject, false);
}
Dictionary<string, string> globalProps = new Dictionary<string, string>(); Dictionary<string, string> globalProps = new Dictionary<string, string>();
globalProps["Configuration"] = configuration; globalProps["Configuration"] = configuration;
globalProps["Platform"] = platform; globalProps["Platform"] = platform;
@ -336,7 +348,9 @@ namespace ICSharpCode.SharpDevelop.Project
if (string.IsNullOrEmpty(toolsVersion)) if (string.IsNullOrEmpty(toolsVersion))
toolsVersion = projectCollection.DefaultToolsVersion; toolsVersion = projectCollection.DefaultToolsVersion;
var project = new MSBuild.Project(projectFile, globalProps, toolsVersion, projectCollection); var project = new MSBuild.Project(projectFile, globalProps, toolsVersion, projectCollection);
return new ConfiguredProject(this, project); if (openCurrentConfiguration)
currentlyOpenProject = project;
return new ConfiguredProject(this, project, !openCurrentConfiguration);
} catch { } catch {
// Leave lock only on exceptions. // Leave lock only on exceptions.
// If there's no exception, the lock will be left when the ConfiguredProject // If there's no exception, the lock will be left when the ConfiguredProject
@ -350,12 +364,14 @@ namespace ICSharpCode.SharpDevelop.Project
sealed class ConfiguredProject : IDisposable sealed class ConfiguredProject : IDisposable
{ {
readonly MSBuildBasedProject p; readonly MSBuildBasedProject p;
readonly bool unloadProjectOnDispose;
public readonly MSBuild.Project Project; public readonly MSBuild.Project Project;
public ConfiguredProject(MSBuildBasedProject parent, MSBuild.Project project) public ConfiguredProject(MSBuildBasedProject parent, MSBuild.Project project, bool unloadProjectOnDispose)
{ {
this.p = parent; this.p = parent;
this.Project = project; this.Project = project;
this.unloadProjectOnDispose = unloadProjectOnDispose;
} }
public MSBuild.ProjectProperty GetNonImportedProperty(string name) public MSBuild.ProjectProperty GetNonImportedProperty(string name)
@ -378,7 +394,9 @@ namespace ICSharpCode.SharpDevelop.Project
public void Dispose() public void Dispose()
{ {
p.projectCollection.UnloadProject(this.Project); if (unloadProjectOnDispose) {
p.projectCollection.UnloadProject(this.Project);
}
System.Threading.Monitor.Exit(p.SyncRoot); System.Threading.Monitor.Exit(p.SyncRoot);
} }
} }
@ -1131,6 +1149,7 @@ namespace ICSharpCode.SharpDevelop.Project
{ {
if (!isLoading) { if (!isLoading) {
lock (SyncRoot) { lock (SyncRoot) {
ReconfigureCurrentlyOpenProject();
CreateItemsListFromMSBuild(); CreateItemsListFromMSBuild();
} }
} }
@ -1141,6 +1160,7 @@ namespace ICSharpCode.SharpDevelop.Project
{ {
if (!isLoading) { if (!isLoading) {
lock (SyncRoot) { lock (SyncRoot) {
ReconfigureCurrentlyOpenProject();
CreateItemsListFromMSBuild(); CreateItemsListFromMSBuild();
} }
} }

Loading…
Cancel
Save