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


C# BuildPropertyGroup.Clone方法代码示例

本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildPropertyGroup.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# BuildPropertyGroup.Clone方法的具体用法?C# BuildPropertyGroup.Clone怎么用?C# BuildPropertyGroup.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.BuildEngine.BuildPropertyGroup的用法示例。


在下文中一共展示了BuildPropertyGroup.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClonePropertyGroup

            public void ClonePropertyGroup()
            {
                BuildPropertyGroup pg = new BuildPropertyGroup();
                pg.SetProperty("foo", "fooval");
                pg.SetProperty(new BuildProperty("bar", "barval", PropertyType.EnvironmentProperty));
                pg.SetProperty(new BuildProperty("baz", "bazval", PropertyType.GlobalProperty));
                pg.SetProperty(new BuildProperty("caz", "cazval", PropertyType.ImportedProperty));
                pg.SetProperty(new BuildProperty("barb", "barbval", PropertyType.OutputProperty));

                pg.SetProperty(new BuildProperty("foo", "fooout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("barb", "barbout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("gaz", "gazout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("foo", "fooout2", PropertyType.OutputProperty));

                BuildPropertyGroup pgsc = pg.Clone(false /* shallow clone */);
                BuildPropertyGroup pgdc = pg.Clone(true /* deep clone */);

                Assertion.AssertEquals(6, pg.Count);
                Assertion.AssertEquals("fooout2", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pg["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pg["gaz"].FinalValueEscaped);

                Assertion.AssertEquals(6, pgsc.Count);
                Assertion.AssertEquals("fooout2", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgsc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgsc["gaz"].FinalValueEscaped);

                Assertion.AssertEquals(6, pgdc.Count);
                Assertion.AssertEquals("fooout2", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgdc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgdc["gaz"].FinalValueEscaped);

                pg.RevertAllOutputProperties();

                Assertion.AssertEquals(4, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
                Assertion.AssertNull(pg["gaz"]);

                Assertion.AssertEquals(6, pgsc.Count);
                Assertion.AssertEquals("fooout2", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgsc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgsc["gaz"].FinalValueEscaped);

                Assertion.AssertEquals(6, pgdc.Count);
                Assertion.AssertEquals("fooout2", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgdc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgdc["gaz"].FinalValueEscaped);

                pgsc.RevertAllOutputProperties();

                Assertion.AssertEquals(4, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
                Assertion.AssertNull(pg["gaz"]);

                Assertion.AssertEquals(4, pgsc.Count);
                Assertion.AssertEquals("fooval", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertNull(pgsc["barb"]);
                Assertion.AssertNull(pgsc["gaz"]);

                Assertion.AssertEquals(6, pgdc.Count);
                Assertion.AssertEquals("fooout2", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgdc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgdc["gaz"].FinalValueEscaped);

                pgdc.RevertAllOutputProperties();

                Assertion.AssertEquals(4, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
//.........这里部分代码省略.........
开发者ID:nikson,项目名称:msbuild,代码行数:101,代码来源:PropertyGroup_Tests.cs

示例2: foreach

        /// <summary>
        /// ImportInitialProperties is used when setting up an evaluated BuildProperty
        /// Group with the initial set of properties from MSBuild reserved properties,
        /// environment variables, tools version dependent properties, and global 
        /// properties.  After this virtual BuildPropertyGroup has been populated with 
        /// these, we can continue to read in the properties from the project file.
        /// </summary>
        /// <param name="environmentProperties"></param>
        /// <param name="reservedProperties"></param>
        /// <param name="toolsVersionDependentProperties"></param>
        /// <param name="globalProperties"></param>
        /// <owner>RGoel</owner>
        internal void ImportInitialProperties
        (
            BuildPropertyGroup environmentProperties, 
            BuildPropertyGroup reservedProperties, 
            BuildPropertyGroup toolsVersionDependentProperties, 
            BuildPropertyGroup globalProperties
        )
        {
            // The consumer of the OM has the ability to add new properties to the 
            // GlobalProperties BuildPropertyGroup, and the OM doesn't expose the 
            // property type, because that would be too dangerous.  So all properties
            // created by the OM consumer will be "normal" properties, even those
            // set in the GlobalProperties BuildPropertyGroup.  But in order to make
            // property precedence work correctly, we should now go through and
            // make sure that all the global properties really are of type "global".
            // However, we don't want to modify the original global property group,
            // so we clone it here.
            BuildPropertyGroup clonedGlobalProperties = globalProperties.Clone(true);

            foreach (BuildProperty globalProperty in clonedGlobalProperties)
            {
                globalProperty.Type = PropertyType.GlobalProperty;
            }

            // Import the environment variables into this virtual BuildPropertyGroup.
            this.ImportProperties(environmentProperties);

            // Import the XMake reserved properties into this virtual BuildPropertyGroup.
            this.ImportProperties(reservedProperties);

            // Import the tools version dependent properties into this virtual BuildPropertyGroup.
            this.ImportProperties(toolsVersionDependentProperties);

            // Import the global properties into this virtual BuildPropertyGroup.
            this.ImportProperties(clonedGlobalProperties);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:48,代码来源:BuildPropertyGroup.cs

示例3: CloneDeepClear

        public void CloneDeepClear()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");

            BuildPropertyGroup clone = group.Clone(true);
            clone.Clear();

            Assertion.AssertEquals(0, clone.Count);
            Assertion.AssertEquals(2, group.Count);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:12,代码来源:BuildPropertyGroup_Tests.cs

示例4: CloneShallowSetProperty

        public void CloneShallowSetProperty()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");

            BuildPropertyGroup clone = group.Clone(false);

            group.SetProperty("n1", "new");

            Assertion.AssertEquals(2, clone.Count);
            Assertion.AssertEquals(2, group.Count);
            Assertion.AssertEquals("new", group["n1"].Value);
            Assertion.AssertEquals("v1", clone["n1"].Value);
            Assertion.AssertEquals(clone["n2"].Value, group["n2"].Value);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:16,代码来源:BuildPropertyGroup_Tests.cs

示例5: ReadEachToolset

 /// <summary>
 /// Reads all the toolsets and populates the given ToolsetCollection with them
 /// </summary>
 /// <param name="toolsets"></param>
 /// <param name="globalProperties"></param>
 /// <param name="initialProperties"></param>
 /// <param name="accumulateProperties"></param>
 private void ReadEachToolset(ToolsetCollection toolsets,
                              BuildPropertyGroup globalProperties,
                              BuildPropertyGroup initialProperties,
                              bool accumulateProperties)
 {
     foreach (PropertyDefinition toolsVersion in ToolsVersions)
     {
         // We clone here because we don't want to interfere with the evaluation 
         // of subsequent Toolsets; otherwise, properties found during the evaluation
         // of this Toolset would be persisted in initialProperties and appear
         // to later Toolsets as Global or Environment properties from the Engine.
         BuildPropertyGroup initialPropertiesClone = initialProperties.Clone(true /* deep clone */);
         Toolset toolset = ReadToolset(toolsVersion, globalProperties, initialPropertiesClone, accumulateProperties);
         if (toolset != null)
         {
             toolsets.Add(toolset);
         }
     }
 }
开发者ID:nikson,项目名称:msbuild,代码行数:26,代码来源:ToolsetReader.cs


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