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


C# TaskItem.CopyMetadataTo方法代码示例

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


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

示例1: CopyMetadataFromITaskItem

        public void CopyMetadataFromITaskItem()
        {
            TaskItem from = new TaskItem();
            from.ItemSpec = "Monkey.txt";
            from.SetMetadata("Dog", "Bingo");
            from.SetMetadata("Cat", "Morris");
            from.SetMetadata("Bird", "Big");

            TaskItem to = new TaskItem();
            to.ItemSpec = "Bonobo.txt";
            to.SetMetadata("Sponge", "Bob");
            to.SetMetadata("Dog", "Harriet");
            to.SetMetadata("Cat", "Mike");
            from.CopyMetadataTo(to);

            Assert.AreEqual("Bonobo.txt", to.ItemSpec);          // ItemSpec is never overwritten
            Assert.AreEqual("Bob", to.GetMetadata("Sponge"));   // Metadata not in source are preserverd.
            Assert.AreEqual("Harriet", to.GetMetadata("Dog"));  // Metadata present on destination are not overwritten.
            Assert.AreEqual("Mike", to.GetMetadata("Cat"));
            Assert.AreEqual("Big", to.GetMetadata("Bird"));
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:21,代码来源:TaskItem_Tests.cs

示例2: SetItemMetadata

        /// <summary>
        /// Set metadata on the items which will be output from RAR.
        /// </summary>
        private ITaskItem SetItemMetadata(ArrayList relatedItems, ArrayList satelliteItems, ArrayList serializationAssemblyItems, ArrayList scatterItems, string fusionName, Reference reference, AssemblyNameExtension assemblyName, FileExists fileExists)
        {
            // Set up the main item.
            ITaskItem referenceItem = new TaskItem();
            referenceItem.ItemSpec = reference.FullPath;
            referenceItem.SetMetadata(ItemMetadataNames.resolvedFrom, reference.ResolvedSearchPath);

            // Set the CopyLocal metadata.
            if (reference.IsCopyLocal)
            {
                referenceItem.SetMetadata(ItemMetadataNames.copyLocal, "true");
            }
            else
            {
                referenceItem.SetMetadata(ItemMetadataNames.copyLocal, "false");
            }

            // Set the FusionName metadata.
            referenceItem.SetMetadata(ItemMetadataNames.fusionName, fusionName);

            // Set the Redist name metadata.
            if (!String.IsNullOrEmpty(reference.RedistName))
            {
                referenceItem.SetMetadata(ItemMetadataNames.redist, reference.RedistName);
            }

            if (Reference.IsFrameworkFile(reference.FullPath, _frameworkPaths) || (_installedAssemblies != null && _installedAssemblies.FrameworkAssemblyEntryInRedist(assemblyName)))
            {
                if (!IsAssemblyRemovedFromDotNetFramework(assemblyName, reference.FullPath, _frameworkPaths, _installedAssemblies))
                {
                    referenceItem.SetMetadata(ItemMetadataNames.frameworkFile, "true");
                }
            }

            if (!String.IsNullOrEmpty(reference.ImageRuntime))
            {
                referenceItem.SetMetadata(ItemMetadataNames.imageRuntime, reference.ImageRuntime);
            }

            if (reference.IsWinMDFile)
            {
                referenceItem.SetMetadata(ItemMetadataNames.winMDFile, "true");

                // The ImplementationAssembly is only set if the implementation file exits on disk
                if (reference.ImplementationAssembly != null)
                {
                    if (VerifyArchitectureOfImplementationDll(reference.ImplementationAssembly, reference.FullPath))
                    {
                        referenceItem.SetMetadata(ItemMetadataNames.winmdImplmentationFile, Path.GetFileName(reference.ImplementationAssembly));

                        // Add the implementation item as a related file
                        ITaskItem item = new TaskItem(reference.ImplementationAssembly);
                        // Clone metadata.
                        referenceItem.CopyMetadataTo(item);
                        // Related files don't have a fusion name.
                        item.SetMetadata(ItemMetadataNames.fusionName, "");
                        RemoveNonForwardableMetadata(item);

                        // Add the related item.
                        relatedItems.Add(item);
                    }
                }

                if (reference.IsManagedWinMDFile)
                {
                    referenceItem.SetMetadata(ItemMetadataNames.winMDFileType, "Managed");
                }
                else
                {
                    referenceItem.SetMetadata(ItemMetadataNames.winMDFileType, "Native");
                }
            }

            // Set the IsRedistRoot metadata
            if (reference.IsRedistRoot == true)
            {
                referenceItem.SetMetadata(ItemMetadataNames.isRedistRoot, "true");
            }
            else if (reference.IsRedistRoot == false)
            {
                referenceItem.SetMetadata(ItemMetadataNames.isRedistRoot, "false");
            }
            else
            {
                // This happens when the redist root is "null". This means there
                // 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.
//.........这里部分代码省略.........
开发者ID:cameron314,项目名称:msbuild,代码行数:101,代码来源:ReferenceTable.cs

示例3: TestCopyMetadataTo

		public void TestCopyMetadataTo ()
		{
			item1 = new TaskItem ("itemSpec");
			item2 = new TaskItem ("itemSpec");
			item1.SetMetadata ("A", "1");
			item1.SetMetadata ("B", "1");
			item1.SetMetadata ("C", "1");
			item2.SetMetadata ("B", "2");
			item1.CopyMetadataTo (item2);
			Assert.AreEqual ("1", item2.GetMetadata ("A"), "1");
			Assert.AreEqual ("2", item2.GetMetadata ("B"), "2");
			Assert.AreEqual ("1", item2.GetMetadata ("C"), "3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:TaskItemTest.cs

示例4: SetItemMetadata

 private static ITaskItem SetItemMetadata(ArrayList relatedItems, ArrayList satelliteItems, ArrayList serializationAssemblyItems, ArrayList scatterItems, string fusionName, Reference reference)
 {
     ITaskItem destinationItem = new TaskItem {
         ItemSpec = reference.FullPath
     };
     destinationItem.SetMetadata("ResolvedFrom", reference.ResolvedSearchPath);
     if (reference.IsCopyLocal)
     {
         destinationItem.SetMetadata("CopyLocal", "true");
     }
     else
     {
         destinationItem.SetMetadata("CopyLocal", "false");
     }
     destinationItem.SetMetadata("FusionName", fusionName);
     if (!string.IsNullOrEmpty(reference.RedistName))
     {
         destinationItem.SetMetadata("Redist", reference.RedistName);
     }
     if (reference.IsRedistRoot == true)
     {
         destinationItem.SetMetadata("IsRedistRoot", "true");
     }
     else if (reference.IsRedistRoot == false)
     {
         destinationItem.SetMetadata("IsRedistRoot", "false");
     }
     if (reference.PrimarySourceItem != null)
     {
         reference.PrimarySourceItem.CopyMetadataTo(destinationItem);
     }
     else
     {
         foreach (ITaskItem item2 in reference.GetSourceItems())
         {
             item2.CopyMetadataTo(destinationItem);
         }
     }
     if (reference.ReferenceVersion != null)
     {
         destinationItem.SetMetadata("Version", reference.ReferenceVersion.ToString());
     }
     else
     {
         destinationItem.SetMetadata("Version", string.Empty);
     }
     foreach (string str in reference.GetRelatedFileExtensions())
     {
         ITaskItem item3 = new TaskItem(reference.FullPathWithoutExtension + str);
         destinationItem.CopyMetadataTo(item3);
         item3.SetMetadata("FusionName", "");
         relatedItems.Add(item3);
     }
     foreach (string str2 in reference.GetSatelliteFiles())
     {
         ITaskItem item4 = new TaskItem(Path.Combine(reference.DirectoryName, str2));
         destinationItem.CopyMetadataTo(item4);
         item4.SetMetadata("DestinationSubDirectory", Microsoft.Build.Shared.FileUtilities.EnsureTrailingSlash(Path.GetDirectoryName(str2)));
         item4.SetMetadata("FusionName", "");
         satelliteItems.Add(item4);
     }
     foreach (string str3 in reference.GetSerializationAssemblyFiles())
     {
         ITaskItem item5 = new TaskItem(Path.Combine(reference.DirectoryName, str3));
         destinationItem.CopyMetadataTo(item5);
         item5.SetMetadata("FusionName", "");
         serializationAssemblyItems.Add(item5);
     }
     foreach (string str4 in reference.GetScatterFiles())
     {
         ITaskItem item6 = new TaskItem(Path.Combine(reference.DirectoryName, str4));
         destinationItem.CopyMetadataTo(item6);
         item6.SetMetadata("FusionName", "");
         scatterItems.Add(item6);
     }
     return destinationItem;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:77,代码来源:ReferenceTable.cs


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