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


C# BuildItemGroup.ToArray方法代码示例

本文整理汇总了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");
                    }
                }
            }
        }
开发者ID:oneminot,项目名称:everest,代码行数:75,代码来源:RimbaCsRenderer.cs

示例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");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:16,代码来源:BuildItemGroupTest.cs

示例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);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:27,代码来源:enginehelpers.cs

示例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");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:15,代码来源:BuildItemGroupTest.cs

示例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);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:10,代码来源:BuildItemGroup_Tests.cs


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