本文整理汇总了C#中Microsoft.GetMetadataValue方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.GetMetadataValue方法的具体用法?C# Microsoft.GetMetadataValue怎么用?C# Microsoft.GetMetadataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.GetMetadataValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpecialCharactersInMetadataValueTests
/// <summary>
/// Helper for metadata escaping tests
/// </summary>
private void SpecialCharactersInMetadataValueTests(Microsoft.Build.Evaluation.ProjectItem item)
{
Assert.AreEqual("%3B", item.GetMetadata("EscapedSemicolon").UnevaluatedValue);
Assert.AreEqual(";", item.GetMetadata("EscapedSemicolon").EvaluatedValue);
Assert.AreEqual(";", item.GetMetadataValue("EscapedSemicolon"));
Assert.AreEqual("%24", item.GetMetadata("EscapedDollarSign").UnevaluatedValue);
Assert.AreEqual("$", item.GetMetadata("EscapedDollarSign").EvaluatedValue);
Assert.AreEqual("$", item.GetMetadataValue("EscapedDollarSign"));
}
示例2: GetPublishSetting
private static bool? GetPublishSetting(Microsoft.Build.Execution.ProjectItemInstance item)
{
bool? publish = null;
string pubValue = item.GetMetadataValue("Publish");
bool pubSetting;
if (!String.IsNullOrWhiteSpace(pubValue) && Boolean.TryParse(pubValue, out pubSetting)) {
publish = pubSetting;
}
return publish;
}
示例3: GetAssemblyFileNameFromHintPath
string GetAssemblyFileNameFromHintPath(Microsoft.Build.Evaluation.Project p, Microsoft.Build.Evaluation.ProjectItem item)
{
string assemblyFileName = null;
if (item.HasMetadata("HintPath"))
{
assemblyFileName = _fileSystem.Path.Combine(p.DirectoryPath, item.GetMetadataValue("HintPath")).ForceNativePathSeparator();
_logger.Info("Looking for assembly from HintPath at " + assemblyFileName);
if (!_fileSystem.File.Exists(assemblyFileName))
{
_logger.Info("Did not find assembly from HintPath");
assemblyFileName = null;
}
}
return assemblyFileName;
}
示例4: GetItemParentNode
/// <summary>
/// Get the parent node of an msbuild item
/// </summary>
/// <param name="item">msbuild item</param>
/// <returns>parent node</returns>
private HierarchyNode GetItemParentNode(Microsoft.Build.Evaluation.ProjectItem item)
{
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)
{
// Use the relative to verify the folders...
currentParent = this.CreateFolderNodes(strPath);
}
return currentParent;
}
示例5: 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>
private HierarchyNode AddIndependentFileNode(Microsoft.Build.Evaluation.ProjectItem item)
{
bool shouldLink = false;
// Remove any redundant "." directories from the Include path.
string includePath = item.Xml.Include.Replace("/./", "/").Replace("\\.\\", "\\");
while (includePath.StartsWith("./", StringComparison.Ordinal) || includePath.StartsWith(".\\", StringComparison.Ordinal))
{
includePath = includePath.Substring(2);
}
// Don't set the property unless necessary to avoid dirtying the project.
if (includePath != item.Xml.Include)
{
item.Xml.Include = includePath;
}
// 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.Xml.Include)).LocalPath;
if (!itemPath.StartsWith(projectFolder, StringComparison.OrdinalIgnoreCase))
{
shouldLink = true;
}
}
HierarchyNode currentParent;
// If the file is outside of the project dir, link to it and place
// it under the project node. Do not attempt to create a '..'
// folder node.
if (shouldLink)
{
currentParent = this;
}
else
{
currentParent = GetItemParentNode(item);
}
HierarchyNode newNode = AddFileNodeToNode(item, currentParent);
if (shouldLink)
{
linkPath = Path.GetFileName(item.Xml.Include);
newNode.ItemNode.SetMetadata(ProjectFileConstants.Link, linkPath);
}
return newNode;
}
示例6: GetMetadataValue
public static string GetMetadataValue(Microsoft.Build.Execution.ProjectItemInstance item, string name)
{
return item.GetMetadataValue(name);
}