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 @@ -68,9 +68,6 @@ namespace ICSharpCode.SharpDevelop.Project
}
#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)
{
if (obj is ItemType)
@ -81,13 +78,11 @@ namespace ICSharpCode.SharpDevelop.Project @@ -81,13 +78,11 @@ namespace ICSharpCode.SharpDevelop.Project
public bool Equals(ItemType other)
{
// add comparisions for all members here
return this.itemName == other.itemName;
}
public override int GetHashCode()
{
// combine the hash codes of all members here (e.g. with XOR operator ^)
return itemName.GetHashCode();
}

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

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

Loading…
Cancel
Save