1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.ComponentModel;
7
using ICSharpCode.Core;
8
using SD = ICSharpCode.SharpDevelop.Project;
9
using ICSharpCode.SharpDevelop.Project;
11
namespace ICSharpCode.PackageManagement.EnvDTE
13
public class ProjectItem
15
SD.FileProjectItem projectItem;
17
public const string CopyToOutputDirectoryPropertyName = "CopyToOutputDirectory";
18
public const string CustomToolPropertyName = "CustomTool";
19
public const string FullPathPropertyName = "FullPath";
21
public ProjectItem(Project project, FileProjectItem projectItem)
23
this.projectItem = projectItem;
24
this.ContainingProject = project;
25
this.ProjectItems = new DirectoryProjectItems(this);
29
void CreateProperties()
31
var propertyFactory = new ProjectItemPropertyFactory(this);
32
Properties = new Properties(propertyFactory);
36
get { return Path.GetFileName(projectItem.Include); }
39
public Properties Properties { get; private set; }
40
public Project ContainingProject { get; private set; }
41
public ProjectItems ProjectItems { get; private set; }
43
internal object GetProperty(string name)
45
if (name == CopyToOutputDirectoryPropertyName) {
46
return GetCopyToOutputDirectory();
47
} else if (name == CustomToolPropertyName) {
48
return projectItem.CustomTool;
49
} else if (name == FullPathPropertyName) {
50
return projectItem.FileName;
55
UInt32 GetCopyToOutputDirectory()
57
return (UInt32)projectItem.CopyToOutputDirectory;
60
internal void SetProperty(string name, object value)
62
if (name == CopyToOutputDirectoryPropertyName) {
63
SetCopyToOutputDirectory(value);
64
} else if (name == CustomToolPropertyName) {
65
projectItem.CustomTool = value as string;
69
void SetCopyToOutputDirectory(object value)
71
CopyToOutputDirectory copyToOutputDirectory = ConvertToCopyToOutputDirectory(value);
72
projectItem.CopyToOutputDirectory = copyToOutputDirectory;
75
CopyToOutputDirectory ConvertToCopyToOutputDirectory(object value)
77
string valueAsString = value.ToString();
78
return (CopyToOutputDirectory)Enum.Parse(typeof(CopyToOutputDirectory), valueAsString);
81
internal bool IsMatchByName(string name)
83
return String.Equals(this.Name, name, StringComparison.InvariantCultureIgnoreCase);
86
internal virtual bool IsChildItem(SD.ProjectItem msbuildProjectItem)
88
string directory = Path.GetDirectoryName(msbuildProjectItem.Include);
89
return IsMatchByName(directory);
92
internal ProjectItemRelationship GetRelationship(SD.ProjectItem msbuildProjectItem)
94
return new ProjectItemRelationship(this, msbuildProjectItem);