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


C# BuildItem.Clone方法代码示例

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


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

示例1: CloneVirtual

        public void CloneVirtual()
        {
            BuildItem item = new BuildItem("n", "i");
            item.SetMetadata("m1", "v1");
            item.SetMetadata("m2", "v2");
            BuildItem clone = item.Clone();

            Assertion.AssertEquals("v1", clone.GetMetadata("m1"));
            Assertion.AssertEquals("v2", clone.GetMetadata("m2"));

            clone.SetMetadata("m2", "newValue");

            Assertion.AssertEquals("v2", item.GetMetadata("m2"));
            Assertion.AssertEquals("newValue", clone.GetMetadata("m2"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:15,代码来源:BuildItem_Tests.cs

示例2: CreateClonedParentedItem

        /// <summary>
        /// Create a clone of the parent item with all the information from the child item.
        /// </summary>
        /// <remarks>
        /// FUTURE: It is unclear what this Whidbey code is for -- the callers already have a child item don't they?
        /// Can this be eliminated to avoid excess cloning?
        /// </remarks>
        internal static BuildItem CreateClonedParentedItem(BuildItem childItem, BuildItem parentItem)
        {
            BuildItem newItem = parentItem.Clone();
            newItem.SetEvaluatedItemSpecEscaped(childItem.EvaluatedItemSpec);
            newItem.SetFinalItemSpecEscaped(childItem.FinalItemSpecEscaped);

            // If this item was defined based on another item, grab that other
            // item's attributes.
            newItem.CloneVirtualMetadata();
            newItem.ImportVirtualMetadataFrom(childItem);

            // BUT if this item itself has attributes declared in the project file,
            // then these should clearly win.
            newItem.ImportVirtualMetadataFrom(parentItem);

            // Set up the parent/child relationship.  The "parent" is the actual item
            // tag as declared in the project file.  The "child" is the item that
            // it evaluated to.  For example, a parent <Blah Include="*.cs"/>
            // may evaluate to many children <Blah Include="a.cs"/>, b.cs, c.cs, etc.
            newItem.ParentPersistedItem = parentItem;
            return newItem;
        }
开发者ID:nikson,项目名称:msbuild,代码行数:29,代码来源:BuildItem.cs

示例3: TestClone1

		public void TestClone1 ()
		{
			item = new BuildItem ("name", "1;2;3");
			item.SetMetadata ("a", "b");

			BuildItem item2 = item.Clone ();

			Assert.AreEqual ("1;2;3", item2.FinalItemSpec, "A1");
			Assert.AreEqual ("1;2;3", item2.Include, "A2");
			Assert.AreEqual (String.Empty, item2.Exclude, "A3");
			Assert.AreEqual (String.Empty, item2.Condition, "A4");
			Assert.AreEqual (false, item2.IsImported, "A5");
			Assert.AreEqual ("name", item2.Name, "A6");
		}
开发者ID:GirlD,项目名称:mono,代码行数:14,代码来源:BuildItemTest.cs

示例4: VirtualClone

        public void VirtualClone()
        {
            BuildItem item = new BuildItem("i", "i1");
            BuildItem clone = item.Clone();

            Assertion.AssertEquals("i", clone.Name);
            Assertion.AssertEquals("i1", clone.EvaluatedItemSpec);
            Assertion.AssertEquals("i1", clone.FinalItemSpec);
            Assertion.AssertEquals("i1", clone.FinalItemSpecEscaped);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:10,代码来源:BuildItem_Tests.cs


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