本文整理汇总了C#中Microsoft.VisualStudio.Package.ProjectElement类的典型用法代码示例。如果您正苦于以下问题:C# ProjectElement类的具体用法?C# ProjectElement怎么用?C# ProjectElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectElement类属于Microsoft.VisualStudio.Package命名空间,在下文中一共展示了ProjectElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HierarchyItemNode
/// <include file='doc\HierarchyItem.uex' path='docs/doc[@for="HierarchyItemNode.HierarchyItemNode"]/*' />
/// <summary>
/// constructor for the HierarchyItemNode
/// </summary>
/// <param name="root"></param>
/// <param name="type"></param>
/// <param name="strDirectoryPath"></param>
public HierarchyItemNode(Project root, HierarchyNodeType type, ProjectElement e)
{
this.projectMgr = root;
this.nodeType = type;
this.itemNode = e;
this.hierarchyId = this.projectMgr.ItemIdMap.Add(this);
}
示例2: WixReferenceNode
// =========================================================================================
// Constructors
// =========================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="WixReferenceNode"/> class.
/// </summary>
/// <param name="root">The root <see cref="WixProjectNode"/> that contains this node.</param>
/// <param name="element">The element that contains MSBuild properties.</param>
protected WixReferenceNode(WixProjectNode root, ProjectElement element)
: base(root, element)
{
string includeValue = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
bool referenceNameNotPresent = String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Name));
string newReferenceName = includeValue;
if (String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.HintPath)))
{
this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, includeValue);
}
if (includeValue.Contains(Path.DirectorySeparatorChar.ToString()))
{
this.ItemNode.Rename(Path.GetFileNameWithoutExtension(includeValue));
newReferenceName = Path.GetFileNameWithoutExtension(includeValue);
}
if (referenceNameNotPresent)
{
// this will fail if the node was included from a targets file
try
{
this.ItemNode.SetMetadata(ProjectFileConstants.Name, newReferenceName);
}
catch
{
}
}
}
示例3: ProjectReferenceNode
/// <summary>
/// Constructor for the ReferenceNode. It is called when the project is reloaded, when the project element representing the refernce exists.
/// </summary>
public ProjectReferenceNode(ProjectNode root, ProjectElement element)
: base(root, element)
{
this.referencedProjectRelativePath = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectRelativePath), "Could not retrive referenced project path form project file");
string guidString = this.ItemNode.GetMetadata(ProjectFileConstants.Project);
// Continue even if project setttings cannot be read.
try
{
this.referencedProjectGuid = new Guid(guidString);
this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid);
this.ProjectMgr.AddBuildDependency(this.buildDependency);
}
finally
{
Debug.Assert(this.referencedProjectGuid != Guid.Empty, "Could not retrive referenced project guidproject file");
this.ReferencedProjectName = this.ItemNode.GetMetadata(ProjectFileConstants.Name);
Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectName), "Could not retrive referenced project name form project file");
}
Uri uri = new Uri(this.ProjectMgr.BaseURI.Uri, this.referencedProjectRelativePath);
if (uri != null)
{
this.referencedProjectFullPath = Microsoft.VisualStudio.Shell.Url.Unescape(uri.LocalPath, true);
}
}
示例4: WixFolderNode
public WixFolderNode(WixProjectNode root, string directoryPath, ProjectElement element, bool isNonMemberItem)
: base(root, directoryPath, element)
{
this.isNonMemberItem = isNonMemberItem;
// Folders do not participate in SCC.
base.ExcludeNodeFromScc = true;
}
示例5: AssemblyReferenceNode
/// <summary>
/// Constructor for the ReferenceNode
/// </summary>
public AssemblyReferenceNode(ProjectNode root, ProjectElement e)
: base(root, e)
{
this.GetPathNameFromProjectFile();
string include = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
CreateFromAssemblyName(new System.Reflection.AssemblyName(include));
}
示例6: Output
/// <summary>
/// Constructor for IVSOutput2 implementation
/// </summary>
/// <param name="projectManager">Project that produce this output</param>
/// <param name="configuration">Configuration that produce this output</param>
/// <param name="outputAssembly">MSBuild generated item corresponding to the output assembly (by default, these would be of type MainAssembly</param>
public Output(ProjectNode projectManager, ProjectConfig configuration, ProjectElement outputAssembly)
{
if (projectManager == null)
throw new ArgumentNullException("projectManager");
if (configuration == null)
throw new ArgumentNullException("configuration");
if (outputAssembly == null)
throw new ArgumentNullException("outputAssembly");
project = projectManager;
projectCfg = configuration;
output = outputAssembly;
}
示例7: ComReferenceNode
/// <summary>
/// Constructor for the ComReferenceNode.
/// </summary>
public ComReferenceNode(ProjectNode root, ProjectElement element)
: base(root, element)
{
this.typeName = this.ItemNode.GetMetadata(ProjectFileConstants.Include);
string typeGuidAsString = this.ItemNode.GetMetadata(ProjectFileConstants.Guid);
if (typeGuidAsString != null)
{
this.typeGuid = new Guid(typeGuidAsString);
}
this.majorVersionNumber = this.ItemNode.GetMetadata(ProjectFileConstants.VersionMajor);
this.minorVersionNumber = this.ItemNode.GetMetadata(ProjectFileConstants.VersionMinor);
this.lcid = this.ItemNode.GetMetadata(ProjectFileConstants.Lcid);
this.SetProjectItemsThatRelyOnReferencesToBeResolved(false);
this.SetInstalledFilePath();
}
示例8: CreateProjectReferenceNode
/// <summary>
/// Creates a project reference node given an existing project element.
/// </summary>
protected virtual ProjectReferenceNode CreateProjectReferenceNode(ProjectElement element)
{
return new ProjectReferenceNode(this.ProjectMgr, element);
}
示例9: CreateComReferenceNode
/// <summary>
/// Creates a com reference node from the project element.
/// </summary>
protected virtual ComReferenceNode CreateComReferenceNode(ProjectElement reference)
{
return new ComReferenceNode(this.ProjectMgr, reference);
}
示例10: CreateAssemblyReferenceNode
/// <summary>
/// Creates an assembly refernce node from a project element.
/// </summary>
protected virtual AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element)
{
AssemblyReferenceNode node = null;
try
{
node = new AssemblyReferenceNode(this.ProjectMgr, element);
}
catch (ArgumentNullException e)
{
Trace.WriteLine("Exception : " + e.Message);
}
catch (FileNotFoundException e)
{
Trace.WriteLine("Exception : " + e.Message);
}
catch (BadImageFormatException e)
{
Trace.WriteLine("Exception : " + e.Message);
}
catch (FileLoadException e)
{
Trace.WriteLine("Exception : " + e.Message);
}
catch (System.Security.SecurityException e)
{
Trace.WriteLine("Exception : " + e.Message);
}
return node;
}
示例11: WixFileNode
public WixFileNode(WixProjectNode root, ProjectElement element, bool isNonMemberItem)
: base(root, element)
{
this.isNonMemberItem = isNonMemberItem;
}
示例12: NestedProjectNode
public NestedProjectNode(ProjectNode root, ProjectElement element)
: base(root, element)
{
this.IsExpanded = true;
}
示例13: ReferenceNode
/// <summary>
/// constructor for the ReferenceNode
/// </summary>
protected ReferenceNode(ProjectNode root, ProjectElement e)
: base(root,e)
{
this.ExcludeNodeFromScc = true;
}
示例14: FileNode
/// <summary>
/// Constructor for the FileNode
/// </summary>
/// <param name="root">Root of the hierarchy</param>
/// <param name="e">Associated project element</param>
public FileNode(ProjectNode root, ProjectElement e)
: base(root, e)
{
if (this.ProjectMgr.NodeHasDesigner(this.ItemNode.GetMetadata(ProjectFileConstants.Include)))
{
this.HasDesigner = true;
}
}
示例15: LoadReferencesFromBuildProject
/// <summary>
/// Adds references to this container from a MSBuild project.
/// </summary>
public void LoadReferencesFromBuildProject(MSBuild.Project buildProject)
{
foreach (string referenceType in SupportedReferenceTypes)
{
MSBuild.BuildItemGroup refererncesGroup = buildProject.GetEvaluatedItemsByName(referenceType);
bool isAssemblyReference = referenceType == ProjectFileConstants.Reference;
// If the project was loaded for browsing we should still create the nodes but as not resolved.
if (this.ProjectMgr.HasPassedSecurityChecks && isAssemblyReference && this.ProjectMgr.Build(MsBuildTarget.ResolveAssemblyReferences) != MSBuildResult.Successful)
{
continue;
}
foreach (MSBuild.BuildItem item in refererncesGroup)
{
ProjectElement element = new ProjectElement(this.ProjectMgr, item, false);
ReferenceNode node = CreateReferenceNode(referenceType, element);
if (node != null)
{
// Make sure that we do not want to add the item twice to the ui hierarchy
// We are using here the UI representation of the Node namely the Caption to find that out, in order to
// avoid different representation problems.
// Example :<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
// <Reference Include="EnvDTE80" />
bool found = false;
for (HierarchyNode n = this.FirstChild; n != null && !found; n = n.NextSibling)
{
if (String.Compare(n.Caption, node.Caption, StringComparison.OrdinalIgnoreCase) == 0)
{
found = true;
}
}
if (!found)
{
this.AddChild(node);
}
}
}
}
}