本文整理汇总了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"));
}
示例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;
}
示例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");
}
示例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);
}