本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildItemGroup类的典型用法代码示例。如果您正苦于以下问题:C# BuildItemGroup类的具体用法?C# BuildItemGroup怎么用?C# BuildItemGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildItemGroup类属于Microsoft.Build.BuildEngine命名空间,在下文中一共展示了BuildItemGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestFalseWhen
public void TestFalseWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == 'False'"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (1, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (0, project.EvaluatedItems.Count, "A3");
Assert.AreEqual (0, project.EvaluatedItemsIgnoringCondition.Count, "A4");
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:BuildChooseTest.cs
示例2: BasicProxying
public void BasicProxying()
{
BuildItemGroup ig = new BuildItemGroup();
BuildItem i1 = new BuildItem("name1", "value1");
i1.SetMetadata("myMetaName", "myMetaValue");
BuildItem i2 = new BuildItem("name2", "value2");
ig.AddItem(i1);
ig.AddItem(i2);
BuildItemGroupProxy proxy = new BuildItemGroupProxy(ig);
// Gather everything into our own table
Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry item in proxy)
{
list.Add(item.Key, item.Value);
}
// Check we got all the items
Assertion.AssertEquals(2, list.Count);
Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
Assertion.AssertEquals("value2", ((TaskItem)list["name2"]).ItemSpec);
// Check they have all their metadata
int builtInMetadata = FileUtilities.ItemSpecModifiers.All.Length;
Assertion.AssertEquals(1 + builtInMetadata, ((TaskItem)list["name1"]).MetadataCount);
Assertion.AssertEquals(0 + builtInMetadata, ((TaskItem)list["name2"]).MetadataCount);
Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));
}
开发者ID:nikson,项目名称:msbuild,代码行数:29,代码来源:BuildItemGroupProxy_Tests.cs
示例3: BuildItemProxy
internal BuildItemProxy(object buildItem)
{
instance = (Microsoft.Build.BuildEngine.BuildItem)buildItem;
// I am not sure what's going on here, but sometimes, in particular when the project is initialized
// the build item is not what we are getting here, but rather the child element
// 'get_ParentPersistedItem" gives us what we need
var persisted_instance = (BuildItem)typeof(BuildItem)
.InvokeMember("get_ParentPersistedItem", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, instance, new object[] { });
if (persisted_instance != null)
instance = persisted_instance;
buildItemGroup = (BuildItemGroup)typeof(BuildItem)
.InvokeMember("get_ParentPersistedItemGroup", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, instance, new object[] { });
int i = -1;
foreach (BuildItem item in buildItemGroup)
{
i++;
if (item == instance)
{
index = i;
break;
}
}
Include = instance.Include;
Type = instance.Name;
}
开发者ID:Hill30,项目名称:F--Project-Extender,代码行数:30,代码来源:BuildItemProxy2008.cs
示例4: BuildWhen
public BuildWhen (XmlElement whenElement, Project parentProject)
{
this.parentProject = parentProject;
this.groupingCollection = new GroupingCollection (parentProject);
if (whenElement == null)
throw new ArgumentNullException ("whenElement");
this.whenElement = whenElement;
foreach (XmlElement xe in whenElement.ChildNodes) {
switch (xe.Name) {
case "ItemGroup":
BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
//big.BindToXml (xe);
groupingCollection.Add (big);
break;
case "PropertyGroup":
BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
//bpg.BindToXml (xe);
groupingCollection.Add (bpg);
break;
case "Choose":
BuildChoose bc = new BuildChoose (xe, parentProject);
groupingCollection.Add (bc);
break;
default:
throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
}
}
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:28,代码来源:BuildWhen.cs
示例5: ExpandAllIntoTaskItems3
public void ExpandAllIntoTaskItems3()
{
BuildPropertyGroup pg = new BuildPropertyGroup();
BuildItemGroup ig = new BuildItemGroup();
ig.AddItem(new BuildItem("Compile", "foo.cs"));
ig.AddItem(new BuildItem("Compile", "bar.cs"));
BuildItemGroup ig2 = new BuildItemGroup();
ig2.AddItem(new BuildItem("Resource", "bing.resx"));
Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
itemsByType["Compile"] = ig;
itemsByType["Resource"] = ig2;
Expander expander = new Expander(pg, itemsByType);
List<TaskItem> itemsOut = expander.ExpandAllIntoTaskItems("foo;bar;@(compile);@(resource)", null);
ObjectModelHelpers.AssertItemsMatch(@"
foo
bar
foo.cs
bar.cs
bing.resx
", itemsOut.ToArray());
}
开发者ID:nikson,项目名称:msbuild,代码行数:27,代码来源:Expander_Tests.cs
示例6: TestCtor
public void TestCtor ()
{
BuildItemGroup big = new BuildItemGroup ();
Assert.AreEqual (String.Empty, big.Condition, "A1");
Assert.AreEqual (0, big.Count, "A2");
Assert.IsFalse (big.IsImported, "A3");
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:8,代码来源:BuildItemGroupTest.cs
示例7: ParameterlessConstructor
public void ParameterlessConstructor()
{
BuildItemGroup group = new BuildItemGroup();
Assertion.AssertEquals(String.Empty, group.Condition);
Assertion.AssertEquals(false, group.IsPersisted);
Assertion.AssertEquals(0, group.Count);
Assertion.AssertEquals(false, group.IsImported);
}
开发者ID:nikson,项目名称:msbuild,代码行数:8,代码来源:BuildItemGroup_Tests.cs
示例8: XmlDocConstructor
public void XmlDocConstructor()
{
XmlDocument doc = new XmlDocument();
BuildItemGroup group = new BuildItemGroup(doc, true, new Project());
Assertion.AssertEquals(String.Empty, group.Condition);
Assert.AreNotEqual(null, group.ItemGroupElement);
Assertion.AssertEquals(0, group.Count);
Assertion.AssertEquals(true, group.IsImported);
}
开发者ID:nikson,项目名称:msbuild,代码行数:9,代码来源:BuildItemGroup_Tests.cs
示例9: SecondaryItemNotShadowedByPrimaryItem
public void SecondaryItemNotShadowedByPrimaryItem()
{
BuildItemGroup group1 = new BuildItemGroup();
group1.AddNewItem("i1", "a1");
Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
table1.Add("i1", group1);
Lookup lookup = LookupHelpers.CreateLookup(table1);
lookup.EnterScope();
// Should return item from the secondary table.
Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);
}
开发者ID:nikson,项目名称:msbuild,代码行数:13,代码来源:Lookup_Tests.cs
示例10: XmlElementConstructor
public void XmlElementConstructor()
{
XmlElement ig = CreatePersistedItemGroupElement();
BuildItemGroup group = new BuildItemGroup(ig, false, new Project());
Assertion.AssertEquals("c", group.Condition);
Assertion.AssertEquals(ig, group.ItemGroupElement);
Assertion.AssertEquals(ig.ParentNode, group.ParentElement);
Assertion.AssertEquals(2, group.Count);
Assertion.AssertEquals(false, group.IsImported);
Assertion.AssertEquals("ci1", group[0].Condition);
Assertion.AssertEquals("i1", group[0].Include);
Assertion.AssertEquals("ci2", group[1].Condition);
Assertion.AssertEquals("i2", group[1].Include);
}
开发者ID:nikson,项目名称:msbuild,代码行数:15,代码来源:BuildItemGroup_Tests.cs
示例11: TestAddNewItem1
public void TestAddNewItem1 ()
{
string name = "name";
string include = "a;b;c";
BuildItemGroup big = new BuildItemGroup ();
BuildItem bi = big.AddNewItem (name, include);
Assert.AreEqual (String.Empty, bi.Condition, "A1");
Assert.AreEqual (String.Empty, bi.Exclude, "A2");
Assert.AreEqual (include, bi.FinalItemSpec, "A3");
Assert.AreEqual (include, bi.Include, "A4");
Assert.IsFalse (bi.IsImported, "A5");
Assert.AreEqual (name, bi.Name, "A6");
Assert.AreEqual (1, big.Count, "A7");
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:16,代码来源:BuildItemGroupTest.cs
示例12: GenerateTestItems
/// <summary>
/// Generate a hashtable of items by type with a bunch of sample items, so that we can exercise
/// ItemExpander.ItemizeItemVector.
/// </summary>
/// <returns></returns>
/// <owner>RGoel</owner>
private Hashtable GenerateTestItems()
{
Hashtable itemGroupsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
// Set up our item group programmatically.
BuildItemGroup itemGroup = new BuildItemGroup();
itemGroupsByType["Compile"] = itemGroup;
BuildItem a = itemGroup.AddNewItem("Compile", "a.cs");
a.SetMetadata("WarningLevel", "4");
BuildItem b = itemGroup.AddNewItem("Compile", "b.cs");
b.SetMetadata("WarningLevel", "3");
BuildItemGroup itemGroup2 = new BuildItemGroup();
itemGroupsByType["Resource"] = itemGroup2;
BuildItem c = itemGroup2.AddNewItem("Resource", "c.resx");
return itemGroupsByType;
}
开发者ID:nikson,项目名称:msbuild,代码行数:24,代码来源:ItemExpander_Tests.cs
示例13: InitiallyNoItemsInBucketOfTypesInItemNames
public void InitiallyNoItemsInBucketOfTypesInItemNames()
{
// This bucket is for items of type "i"
string[] itemNames = new string[] { "i" };
// There are items of type "i" and "j" available in the project, though
BuildItemGroup group1 = new BuildItemGroup();
BuildItemGroup group2 = new BuildItemGroup();
group1.AddNewItem("i", "i1");
group2.AddNewItem("j", "j1");
Hashtable items = new Hashtable(StringComparer.OrdinalIgnoreCase);
items.Add("i", group1);
items.Add("j", group2);
Lookup lookup = LookupHelpers.CreateLookup(items);
ItemBucket bucket = new ItemBucket(itemNames, new Dictionary<string, string>(), lookup, 0);
// No items of type i
Assertion.AssertEquals(0, bucket.Lookup.GetItems("i1").Count);
// Items of type j, however, are visible
Assertion.AssertEquals(1, bucket.Lookup.GetItems("j").Count);
}
开发者ID:nikson,项目名称:msbuild,代码行数:22,代码来源:ItemBucket_Tests.cs
示例14: CantModifyThroughEnumerator
public void CantModifyThroughEnumerator()
{
BuildItemGroup ig = new BuildItemGroup();
BuildItem i1 = new BuildItem("name1", "value1");
i1.SetMetadata("myMetaName", "myMetaValue");
ig.AddItem(i1);
BuildItemGroupProxy proxy = new BuildItemGroupProxy(ig);
Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry item in proxy)
{
list.Add(item.Key, item.Value);
}
// Change the item
Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
((TaskItem)list["name1"]).ItemSpec = "newItemSpec";
((TaskItem)list["name1"]).SetMetadata("newMetadata", "newMetadataValue");
// We did change our copy
Assertion.AssertEquals("newItemSpec", ((TaskItem)list["name1"]).ItemSpec);
Assertion.AssertEquals("newMetadataValue", ((TaskItem)list["name1"]).GetMetadata("newMetadata"));
Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));
// But get the item again
list = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry item in proxy)
{
list.Add(item.Key, item.Value);
}
// Item value and metadata hasn't changed
Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
Assertion.AssertEquals("", ((TaskItem)list["name1"]).GetMetadata("newMetadata"));
Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));
}
开发者ID:nikson,项目名称:msbuild,代码行数:37,代码来源:BuildItemGroupProxy_Tests.cs
示例15: SetupMembers
private void SetupMembers()
{
pg1 = new BuildPropertyGroup();
pg1.SetProperty("foo", "bar");
pg1.SetProperty("abc", "true");
pg1.SetProperty("Unit", "inches");
pg2 = new BuildPropertyGroup();
pg2.SetProperty("foo", "bar");
pg2.SetProperty("abc", "true");
pg3 = new BuildPropertyGroup();
// These Choose objects are only suitable for
// holding a place in the GroupingCollection.
choose1 = new Choose();
choose2 = new Choose();
choose3 = new Choose();
ig1 = new BuildItemGroup();
ig1.AddNewItem("x", "x1");
ig1.AddNewItem("x", "x2");
ig1.AddNewItem("y", "y1");
ig1.AddNewItem("y", "y2");
ig1.AddNewItem("y", "y3");
ig1.AddNewItem("y", "y4");
ig2 = new BuildItemGroup();
ig2.AddNewItem("jacksonfive", "germaine");
ig2.AddNewItem("jacksonfive", "tito");
ig2.AddNewItem("jacksonfive", "michael");
ig2.AddNewItem("jacksonfive", "latoya");
ig2.AddNewItem("jacksonfive", "janet");
ig3 = new BuildItemGroup();
}
开发者ID:nikson,项目名称:msbuild,代码行数:36,代码来源:GroupingCollection_Tests.cs
示例16: AddEvaluatedItem
void AddEvaluatedItem (Project project, bool evaluatedTo, ITaskItem taskitem)
{
if (IsDynamic && evaluatedTo && !KeepDuplicates && ContainsItem (project, taskitem))
return;
BuildItemGroup big;
BuildItem bi = new BuildItem (this);
bi.finalItemSpec = taskitem.ItemSpec;
foreach (DictionaryEntry de in taskitem.CloneCustomMetadata ()) {
bi.unevaluatedMetadata.Add ((string) de.Key, (string) de.Value);
bi.evaluatedMetadata.Add ((string) de.Key, (string) de.Value);
}
project.EvaluatedItemsIgnoringCondition.AddItem (bi);
if (evaluatedTo) {
project.EvaluatedItems.AddItem (bi);
if (!project.EvaluatedItemsByName.ContainsKey (bi.Name)) {
big = new BuildItemGroup (null, project, null, true);
project.EvaluatedItemsByName.Add (bi.Name, big);
} else {
big = project.EvaluatedItemsByName [bi.Name];
}
big.AddItem (bi);
}
if (!project.EvaluatedItemsByNameIgnoringCondition.ContainsKey (bi.Name)) {
big = new BuildItemGroup (null, project, null, true);
project.EvaluatedItemsByNameIgnoringCondition.Add (bi.Name, big);
} else {
big = project.EvaluatedItemsByNameIgnoringCondition [bi.Name];
}
big.AddItem (bi);
if (IsDynamic)
AddAndRemoveMetadata (project, bi);
}
开发者ID:GirlD,项目名称:mono,代码行数:41,代码来源:BuildItem.cs
示例17: GetBuckets
public void GetBuckets()
{
List<string> parameters = new List<string>();
parameters.Add("@(File);$(unittests)");
parameters.Add("$(obj)\\%(Filename).ext");
parameters.Add("@(File->'%(extension)')"); // attributes in transforms don't affect batching
Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
BuildItemGroup items = new BuildItemGroup();
items.AddNewItem("File", "a.foo");
items.AddNewItem("File", "b.foo");
items.AddNewItem("File", "c.foo");
items.AddNewItem("File", "d.foo");
items.AddNewItem("File", "e.foo");
itemsByType["FILE"] = items;
items = new BuildItemGroup();
items.AddNewItem("Doc", "a.doc");
items.AddNewItem("Doc", "b.doc");
items.AddNewItem("Doc", "c.doc");
items.AddNewItem("Doc", "d.doc");
items.AddNewItem("Doc", "e.doc");
itemsByType["DOC"] = items;
BuildPropertyGroup properties = new BuildPropertyGroup();
properties.SetProperty("UnitTests", "unittests.foo");
properties.SetProperty("OBJ", "obj");
ArrayList buckets = BatchingEngine.PrepareBatchingBuckets(new XmlDocument().CreateElement("Foo"), parameters, CreateLookup(itemsByType, properties));
Assertion.AssertEquals(5, buckets.Count);
foreach (ItemBucket bucket in buckets)
{
// non-batching data -- same for all buckets
XmlAttribute tempXmlAttribute = (new XmlDocument()).CreateAttribute("attrib");
tempXmlAttribute.Value = "'$(Obj)'=='obj'";
Assertion.Assert(BuildEngine.Utilities.EvaluateCondition(tempXmlAttribute.Value,
tempXmlAttribute, bucket.Expander, null, ParserOptions.AllowAll, null, null));
Assertion.AssertEquals("a.doc;b.doc;c.doc;d.doc;e.doc", ExpandItemsIntoString(bucket, "@(doc)"));
Assertion.AssertEquals("unittests.foo", ExpandMetadataAndProperties(bucket, "$(bogus)$(UNITTESTS)"));
}
Assertion.AssertEquals("a.foo", ExpandItemsIntoString((ItemBucket)buckets[0], "@(File)"));
Assertion.AssertEquals(".foo", ExpandItemsIntoString((ItemBucket)buckets[0], "@(File->'%(Extension)')"));
Assertion.AssertEquals("obj\\a.ext", ExpandMetadataAndProperties((ItemBucket)buckets[0], "$(obj)\\%(Filename).ext"));
// we weren't batching on this attribute, so it has no value
Assertion.AssertEquals(String.Empty, ExpandMetadataAndProperties((ItemBucket)buckets[0], "%(Extension)"));
items = ((ItemBucket)buckets[0]).Expander.ExpandSingleItemListExpressionIntoItemsLeaveEscaped("@(file)", null);
Assertion.AssertNotNull(items);
Assertion.AssertEquals(1, items.Count);
int invalidProjectFileExceptions = 0;
try
{
// This should throw because we don't allow item lists to be concatenated
// with other strings.
items = ((ItemBucket)buckets[0]).Expander.ExpandSingleItemListExpressionIntoItemsLeaveEscaped("@(file);$(unitests)", null);
}
catch (InvalidProjectFileException)
{
invalidProjectFileExceptions++;
}
// We do allow separators in item vectors, this results in an item group with a single flattened item
items = ((ItemBucket)buckets[0]).Expander.ExpandSingleItemListExpressionIntoItemsLeaveEscaped("@(file, ',')", null);
Assertion.AssertNotNull(items);
Assertion.AssertEquals(1, items.Count);
Assertion.AssertEquals("a.foo", items[0].FinalItemSpec);
Assertion.AssertEquals(1, invalidProjectFileExceptions);
}
开发者ID:nikson,项目名称:msbuild,代码行数:76,代码来源:BatchingEngine_Tests.cs
示例18: Regress_Mutation_DuplicateBatchingBucketsAreFoldedTogether
public void Regress_Mutation_DuplicateBatchingBucketsAreFoldedTogether()
{
List<string> parameters = new List<string>();
parameters.Add("%(File.Culture)");
Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
BuildItemGroup items = new BuildItemGroup();
items.AddNewItem("File", "a.foo");
items.AddNewItem("File", "b.foo"); // Need at least two items for this test case to ensure multiple buckets might be possible
itemsByType["FILE"] = items;
BuildPropertyGroup properties = new BuildPropertyGroup();
ArrayList buckets = BatchingEngine.PrepareBatchingBuckets(new XmlDocument().CreateElement("Foo"), parameters, CreateLookup(itemsByType, properties));
// If duplicate buckes have been folded correctly, then there will be exactly one bucket here
// containing both a.foo and b.foo.
Assertion.AssertEquals(1, buckets.Count);
}
开发者ID:nikson,项目名称:msbuild,代码行数:20,代码来源:BatchingEngine_Tests.cs
示例19: InvalidUnqualifiedMetadataReference
public void InvalidUnqualifiedMetadataReference()
{
List<string> parameters = new List<string>();
parameters.Add("@(File)");
parameters.Add("%(Culture)");
Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
BuildItemGroup items = new BuildItemGroup();
itemsByType["FILE"] = items;
BuildItem a = items.AddNewItem("File", "a.foo");
BuildItem b = items.AddNewItem("File", "b.foo");
a.SetMetadata("Culture", "fr-fr");
BuildPropertyGroup properties = new BuildPropertyGroup();
// This is expected to throw because not all items contain a value for metadata "Culture".
// Only a.foo has a Culture metadata. b.foo does not.
ArrayList buckets = BatchingEngine.PrepareBatchingBuckets(new XmlDocument().CreateElement("Foo"), parameters, CreateLookup(itemsByType, properties));
}
开发者ID:nikson,项目名称:msbuild,代码行数:21,代码来源:BatchingEngine_Tests.cs
示例20: ValidUnqualifiedMetadataReference
public void ValidUnqualifiedMetadataReference()
{
List<string> parameters = new List<string>();
parameters.Add("@(File)");
parameters.Add("%(Culture)");
Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
BuildItemGroup items = new BuildItemGroup();
itemsByType["FILE"] = items;
BuildItem a = items.AddNewItem("File", "a.foo");
BuildItem b = items.AddNewItem("File", "b.foo");
a.SetMetadata("Culture", "fr-fr");
b.SetMetadata("Culture", "en-en");
BuildPropertyGroup properties = new BuildPropertyGroup();
ArrayList buckets = BatchingEngine.PrepareBatchingBuckets(new XmlDocument().CreateElement("Foo"), parameters, CreateLookup(itemsByType, properties));
Assertion.AssertEquals(2, buckets.Count);
}
开发者ID:nikson,项目名称:msbuild,代码行数:21,代码来源:BatchingEngine_Tests.cs
注:本文中的Microsoft.Build.BuildEngine.BuildItemGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论