本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildItemGroup.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# BuildItemGroup.ToArray方法的具体用法?C# BuildItemGroup.ToArray怎么用?C# BuildItemGroup.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.BuildItemGroup
的用法示例。
在下文中一共展示了BuildItemGroup.ToArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderFeatureList
/// <summary>
/// Render feature list
/// </summary>
private void RenderFeatureList(List<Feature> features, string[][] templateFields, List<KeyValuePair<FeatureRendererAttribute, IFeatureRenderer>> renderers, BuildItemGroup fileItemGroup, BuildItemGroup mobileItemGroup, Dictionary<String, StringCollection> parameters)
{
// Scan the class repo and start processing
foreach (Feature f in features)
{
System.Diagnostics.Trace.WriteLine(String.Format("Rendering C# for '{0}'...", f.Name), "debug");
// Is there a renderer for this feature
KeyValuePair<FeatureRendererAttribute, IFeatureRenderer> fr = renderers.Find(o => o.Key.Feature == f.GetType());
// Was a renderer found?
if (fr.Key == null)
System.Diagnostics.Trace.WriteLine(String.Format("can't find renderer for {0}", f.GetType().Name), "warn");
else
{
string file = String.Empty;
try // To write the file
{
// Start the rendering
file = fr.Value.CreateFile(f, hostContext.Output);
// Is the renderer for a file
if (fr.Key.IsFile)
{
TextWriter tw = File.CreateText(file);
try // Render the file
{
string Header = Template.Default; // Set the header to the default
// Populate template fields
foreach (String[] st in templateFields)
Header = Header.Replace(st[0], st[1]);
// Write header
tw.Write(Header);
// Render the template out
fr.Value.Render(parameters["rimbapi-target-ns"][0], parameters["rimbapi-api-ns"][0], f, tw);
}
finally
{
tw.Close();
}
// Add to the files in the project
string projName = file.Replace(hostContext.Output, "");
if (projName.StartsWith(Path.DirectorySeparatorChar.ToString()))
projName = projName.Substring(1);
if (Array.Find<BuildItem>(fileItemGroup.ToArray(), itm => itm.Include.Equals(projName)) == null)
{
fileItemGroup.AddNewItem("Compile", projName);
mobileItemGroup.AddNewItem("Compile", projName);
}
else
Trace.WriteLine(String.Format("Class '{0}' is defined more than once, second include is ignored", projName), "warn");
}
}
catch (NotSupportedException)
{
if (!String.IsNullOrEmpty(file)) File.Delete(file);
}
catch (Exception e)
{
if (!String.IsNullOrEmpty(file)) File.Delete(file);
System.Diagnostics.Trace.WriteLine(e.Message, "error");
}
}
}
}
示例2: TestToArray1
public void TestToArray1 ()
{
BuildItemGroup big = new BuildItemGroup ();
BuildItem[] items = big.ToArray ();
Assert.AreEqual (0, items.Length, "A1");
big.AddNewItem ("a", "b");
big.AddNewItem ("c", "d");
items = big.ToArray ();
Assert.AreEqual ("a", items [0].Name, "A2");
Assert.AreEqual ("c", items [1].Name, "A3");
}
示例3: AssertItemsMatch
/// <summary>
/// Amazingly sophisticated :) helper function to determine if the set of ITaskItems returned from
/// a task match the expected set of ITaskItems. It can also check that the ITaskItems have the expected
/// metadata, and that the ITaskItems are returned in the correct order.
///
/// The "expectedItemsString" is a formatted way of easily specifying which items you expect to see.
/// The format is:
///
/// itemspec1 : metadataname1=metadatavalue1 ; metadataname2=metadatavalue2 ; ...
/// itemspec2 : metadataname3=metadatavalue3 ; metadataname4=metadatavalue4 ; ...
/// itemspec3 : metadataname5=metadatavalue5 ; metadataname6=metadatavalue6 ; ...
///
/// (Each item needs to be on its own line.)
///
/// </summary>
/// <param name="expectedItemsString"></param>
/// <param name="actualItems"></param>
/// <owner>RGoel</owner>
static internal void AssertItemsMatch
(
string expectedItemsString,
BuildItemGroup actualItems,
bool orderOfItemsShouldMatch
)
{
AssertItemsMatch(expectedItemsString, actualItems.ToArray(), orderOfItemsShouldMatch);
}
示例4: TestRemoveItemAt1
public void TestRemoveItemAt1 ()
{
BuildItemGroup big = new BuildItemGroup ();
big.AddNewItem ("a", "b");
big.AddNewItem ("b", "c");
big.AddNewItem ("c", "d");
big.RemoveItemAt (1);
BuildItem[] items = big.ToArray ();
Assert.AreEqual (2, big.Count, "A1");
Assert.AreEqual ("a", items [0].Name, "A2");
Assert.AreEqual ("c", items [1].Name, "A3");
}
示例5: ToArray
public void ToArray()
{
XmlElement ig = CreatePersistedItemGroupElement();
BuildItemGroup group = new BuildItemGroup(ig, false, new Project());
BuildItem[] array = group.ToArray();
Assertion.AssertEquals(2, array.Length);
Assertion.AssertEquals("i1", array[0].Include);
Assertion.AssertEquals("i2", array[1].Include);
}