当前位置: 首页>>代码示例>>C#>>正文


C# TaskItem.RemoveMetadata方法代码示例

本文整理汇总了C#中Microsoft.Build.Utilities.TaskItem.RemoveMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# TaskItem.RemoveMetadata方法的具体用法?C# TaskItem.RemoveMetadata怎么用?C# TaskItem.RemoveMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.Utilities.TaskItem的用法示例。


在下文中一共展示了TaskItem.RemoveMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetItemMetadata


//.........这里部分代码省略.........
                // was no IsRedistRoot flag in the Redist XML (or there was no 
                // redist XML at all for this item).
            }

            // If there was a primary source item, then forward metadata from it.
            // It's important that the metadata from the primary source item
            // win over the same metadata from other source items, so that's
            // why we put this first.  (CopyMetadataTo will never override an 
            // already existing metadata.)  For example, if this reference actually
            // came directly from an item declared in the project file, we'd
            // want to use the metadata from it, not some other random item in
            // the project file that happened to have this reference as a dependency.
            if (reference.PrimarySourceItem != null)
            {
                reference.PrimarySourceItem.CopyMetadataTo(referenceItem);
            }
            else
            {
                bool hasImplementationFile = referenceItem.GetMetadata(ItemMetadataNames.winmdImplmentationFile).Length > 0;
                bool hasImageRuntime = referenceItem.GetMetadata(ItemMetadataNames.imageRuntime).Length > 0;
                bool hasWinMDFile = referenceItem.GetMetadata(ItemMetadataNames.winMDFile).Length > 0;

                // If there were non-primary source items, then forward metadata from them.
                ICollection sourceItems = reference.GetSourceItems();
                foreach (ITaskItem sourceItem in sourceItems)
                {
                    sourceItem.CopyMetadataTo(referenceItem);
                }

                // If the item originally did not have the implementation file metadata then we do not want to get it from the set of primary source items
                // since the implementation file is something specific to the source item and not supposed to be propigated.
                if (!hasImplementationFile)
                {
                    referenceItem.RemoveMetadata(ItemMetadataNames.winmdImplmentationFile);
                }

                // If the item originally did not have the ImageRuntime metadata then we do not want to get it from the set of primary source items
                // since the ImageRuntime is something specific to the source item and not supposed to be propigated.
                if (!hasImageRuntime)
                {
                    referenceItem.RemoveMetadata(ItemMetadataNames.imageRuntime);
                }

                // If the item originally did not have the WinMDFile metadata then we do not want to get it from the set of primary source items
                // since the WinMDFile is something specific to the source item and not supposed to be propigated
                if (!hasWinMDFile)
                {
                    referenceItem.RemoveMetadata(ItemMetadataNames.winMDFile);
                }
            }

            if (reference.ReferenceVersion != null)
            {
                referenceItem.SetMetadata(ItemMetadataNames.version, reference.ReferenceVersion.ToString());
            }
            else
            {
                referenceItem.SetMetadata(ItemMetadataNames.version, String.Empty);
            }

            // Now clone all properties onto the related files.
            foreach (string relatedFileExtension in reference.GetRelatedFileExtensions())
            {
                ITaskItem item = new TaskItem(reference.FullPathWithoutExtension + relatedFileExtension);
                // Clone metadata.
                referenceItem.CopyMetadataTo(item);
开发者ID:cameron314,项目名称:msbuild,代码行数:67,代码来源:ReferenceTable.cs

示例2: CannotRemoveModifiers

        public void CannotRemoveModifiers()
        {
            TaskItem t = new TaskItem("foor");

            try
            {
                t.RemoveMetadata(FileUtilities.ItemSpecModifiers.RootDir);
            }
            catch (Exception e)
            {
                // so I can see the exception message in NUnit's "Standard Out" window
                Console.WriteLine(e.Message);
                throw;
            }
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:15,代码来源:TaskItem_Tests.cs


注:本文中的Microsoft.Build.Utilities.TaskItem.RemoveMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。