本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildItemGroup.AddExistingItem方法的典型用法代码示例。如果您正苦于以下问题:C# BuildItemGroup.AddExistingItem方法的具体用法?C# BuildItemGroup.AddExistingItem怎么用?C# BuildItemGroup.AddExistingItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.BuildItemGroup
的用法示例。
在下文中一共展示了BuildItemGroup.AddExistingItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
/// <summary>
/// Evaluates the item and returns a virtual group containing any resulting items.
/// This allows an item to be evaluated without it belonging to an item group.
/// </summary>
internal BuildItemGroup Evaluate(Expander expander,
string baseDirectory,
bool expandMetadata,
ParserOptions parserOptions,
EngineLoggingServices loggingServices,
BuildEventContext buildEventContext)
{
BuildItemGroup result = new BuildItemGroup();
bool itemCondition = Utilities.EvaluateCondition(Condition,
ConditionAttribute,
expander,
parserOptions,
loggingServices,
buildEventContext);
if (!itemCondition)
{
return result;
}
EvaluateAllItemMetadata(expander, parserOptions, loggingServices, buildEventContext);
BuildItemGroup items = BuildItemGroup.ExpandItemIntoItems(baseDirectory, this, expander, expandMetadata);
for (int i = 0; i < items.Count; i++)
{
BuildItem newItem = CreateClonedParentedItem(items[i], this);
result.AddExistingItem(newItem);
}
return result;
}
示例2: ModifyItemInProjectPreviouslyModifiedAndGottenThroughGetItem
public void ModifyItemInProjectPreviouslyModifiedAndGottenThroughGetItem()
{
// Create some project state with an item with m=m1 and n=n1
Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
BuildItem item1 = new BuildItem("i1", "a2");
item1.SetMetadata("m", "m1");
BuildItemGroup group0 = new BuildItemGroup();
group0.AddExistingItem(item1);
table1["i1"] = group0;
Lookup lookup = LookupHelpers.CreateLookup(table1);
lookup.EnterScope();
// Make a modification to the item to be m=m2
Dictionary<string, string> newMetadata = new Dictionary<string, string>();
newMetadata.Add("m", "m2");
BuildItemGroup group = new BuildItemGroup();
group.AddItem(item1);
lookup.ModifyItems(item1.Name, group, newMetadata);
// Get the item (under the covers, it cloned it in order to apply the modification)
BuildItemGroup group2 = lookup.GetItems(item1.Name);
Assertion.AssertEquals(1, group2.Count);
BuildItem item1b = group2[0];
// Modify to m=m3
Dictionary<string, string> newMetadata2 = new Dictionary<string, string>();
newMetadata2.Add("m", "m3");
BuildItemGroup group3 = new BuildItemGroup();
group3.AddItem(item1b);
lookup.ModifyItems(item1b.Name, group3, newMetadata2);
// Modifications are visible
BuildItemGroup group4 = lookup.GetItems(item1b.Name);
Assertion.AssertEquals(1, group4.Count);
Assertion.AssertEquals("m3", group4[0].GetMetadata("m"));
// Leave scope
lookup.LeaveScope();
// Still visible
BuildItemGroup group5 = lookup.GetItems(item1b.Name);
Assertion.AssertEquals(1, group5.Count);
Assertion.AssertEquals("m3", group5[0].GetMetadata("m"));
// And the one in the project is changed
Assertion.AssertEquals("m3", item1.GetMetadata("m"));
}
示例3: RemoveItemFromProjectPreviouslyModifiedAndGottenThroughGetItem
public void RemoveItemFromProjectPreviouslyModifiedAndGottenThroughGetItem()
{
// Create some project state with an item with m=m1 and n=n1
Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
BuildItem item1 = new BuildItem("i1", "a2");
item1.SetMetadata("m", "m1");
BuildItemGroup group0 = new BuildItemGroup();
group0.AddExistingItem(item1);
table1["i1"] = group0;
Lookup lookup = LookupHelpers.CreateLookup(table1);
lookup.EnterScope();
// Make a modification to the item to be m=m2
Dictionary<string, string> newMetadata = new Dictionary<string, string>();
newMetadata.Add("m", "m2");
BuildItemGroup group = new BuildItemGroup();
group.AddItem(item1);
lookup.ModifyItems(item1.Name, group, newMetadata);
// Get the item (under the covers, it cloned it in order to apply the modification)
BuildItemGroup group2 = lookup.GetItems(item1.Name);
Assertion.AssertEquals(1, group2.Count);
BuildItem item1b = group2[0];
// Remove the item
lookup.RemoveItem(item1b);
// There's now no items at all
BuildItemGroup group3 = lookup.GetItems(item1.Name);
Assertion.AssertEquals(0, group3.Count);
// Leave scope
lookup.LeaveScope();
// And now none left in the project either
Assertion.AssertEquals(0, ((BuildItemGroup)table1["i1"]).Count);
}
示例4: Backup1
public void Backup1()
{
BuildItemGroup group = new BuildItemGroup(); // virtual group
XmlElement element = CreatePersistedItemGroupElement();
BuildItem item1 = CreatePersistedBuildItem(element, "i", "i1");
BuildItem item2 = CreatePersistedBuildItem(element, "i", "i2");
group.AddExistingItem(item1);
group.AddExistingItem(item2);
BuildItem item3 = group.AddNewItem("j", "j1"); // virtual
Assertion.AssertEquals(3, group.Count);
group.RemoveItemWithBackup(item3);
group.RemoveItemWithBackup(item1);
Assertion.AssertEquals(1, group.Count);
group.RemoveAllIntermediateItems();
Assertion.AssertEquals(2, group.Count);
}