本文整理汇总了C#中Microsoft.Build.Evaluation.GetMetadataValue方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Build.Evaluation.GetMetadataValue方法的具体用法?C# Microsoft.Build.Evaluation.GetMetadataValue怎么用?C# Microsoft.Build.Evaluation.GetMetadataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Evaluation
的用法示例。
在下文中一共展示了Microsoft.Build.Evaluation.GetMetadataValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMetadataValue
public static string GetMetadataValue(MSBuild.ProjectItem item, string name)
{
return item.GetMetadataValue(name);
}
示例2: GetItemParentNode
/// <summary>
/// Get the parent node of an msbuild item
/// </summary>
/// <param name="item">msbuild item</param>
/// <returns>parent node</returns>
protected virtual HierarchyNode GetItemParentNode(MSBuild.ProjectItem item, IDictionary<string, HierarchyNode> nodeCache)
{
if (item == null)
throw new ArgumentNullException("item");
if (nodeCache == null)
throw new ArgumentNullException("nodeCache");
//Contract.Ensures(Contract.Result<HierarchyNode>() != null);
HierarchyNode currentParent = this;
string strPath = item.EvaluatedInclude;
string link = item.GetMetadataValue(ProjectFileConstants.Link);
if (!string.IsNullOrEmpty(link))
strPath = link;
strPath = Path.GetDirectoryName(strPath);
if (strPath.Length > 0)
{
if (!nodeCache.TryGetValue(strPath, out currentParent))
{
// Use the relative to verify the folders...
currentParent = this.CreateFolderNodes(strPath, nodeCache);
nodeCache.Add(strPath, currentParent);
}
}
return currentParent;
}
示例3: GetItemParentNode
/// <summary>
/// Get the parent node of an msbuild item
/// </summary>
/// <param name="item">msbuild item</param>
/// <returns>parent node</returns>
private HierarchyNode GetItemParentNode(MSBuild.ProjectItem item)
{
var isLink = IsLinkNode(item);
var path = isLink ? item.GetMetadataValue("Link") : item.EvaluatedInclude;
var dir = Path.GetDirectoryName(path);
return Path.IsPathRooted(dir) || string.IsNullOrEmpty(dir)
? this : CreateFolderNodes(dir);
}
示例4: AddIndependentFileNode
/// <summary>
/// Add an item to the hierarchy based on the item path
/// </summary>
/// <param name="item">Item to add</param>
/// <returns>Added node</returns>
protected virtual HierarchyNode AddIndependentFileNode(MSBuild.ProjectItem item, IDictionary<string, HierarchyNode> parentNodeCache)
{
if (item == null)
throw new ArgumentNullException("item");
if (parentNodeCache == null)
throw new ArgumentNullException("parentNodeCache");
//Contract.Ensures(Contract.Result<HierarchyNode>() != null);
// Make sure the item is within the project folder hierarchy. If not, link it.
string linkPath = item.GetMetadataValue(ProjectFileConstants.Link);
if (String.IsNullOrEmpty(linkPath))
{
string projectFolder = new Uri(this.ProjectFolder).LocalPath;
string itemPath = new Uri(Path.Combine(this.ProjectFolder, item.EvaluatedInclude)).LocalPath;
if (!itemPath.StartsWith(projectFolder, StringComparison.OrdinalIgnoreCase))
{
linkPath = Path.GetFileName(item.EvaluatedInclude);
item.SetMetadataValue(ProjectFileConstants.Link, linkPath);
}
}
HierarchyNode currentParent = GetItemParentNode(item, parentNodeCache);
return AddFileNodeToNode(item, currentParent);
}
示例5: GetItemParentNode
/// <summary>
/// Get the parent node of an msbuild item
/// </summary>
/// <param name="item">msbuild item</param>
/// <returns>parent node</returns>
private HierarchyNode GetItemParentNode(MSBuild.ProjectItem item)
{
HierarchyNode currentParent = this;
string strPath;
// !EFW
// If it's a link, use the linked path for the node
strPath = item.GetMetadataValue(ProjectFileConstants.Link);
if(String.IsNullOrEmpty(strPath))
strPath = item.EvaluatedInclude;
strPath = Path.GetDirectoryName(strPath);
if(strPath.Length > 0)
{
// Use the relative to verify the folders...
currentParent = this.CreateFolderNodes(strPath);
}
return currentParent;
}