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


C# BuildPropertyGroup.Evaluate方法代码示例

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


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

示例1: foreach

        /// <summary>
        /// Process each of the direct children beneath the &gt;Project&lt; element.
        /// These include things like &lt;PropertyGroup&gt;, &lt;ItemGroup&gt;, &lt;Target&gt;, etc.
        /// This method is simply capturing the data in the form of our own
        /// internal objects.  It is not actually evaluating any of the properties
        /// or other data.
        /// </summary>
        /// <param name="projectElement"></param>
        /// <param name="projectDirectoryLocation"></param>
        /// <param name="importedProject"></param>
        /// <owner>RGoel</owner>
        private void ProcessProjectChildren
        (
            XmlElement projectElement,
            string projectDirectoryLocation,
            bool importedProject
        )
        {
            // Make sure the <Project> node has been given to us.
            error.VerifyThrow(projectElement != null,
                "Need an XML node representing the <project> element.");

            // Make sure this really is the <Project> node.
            ProjectXmlUtilities.VerifyThrowElementName(projectElement, XMakeElements.project);

            // Loop through all the direct children of the <project> element.
            // This verifies all the XML is legitimate, and creates ordered lists of objects
            // representing the top-level nodes (itemgroup, choose, etc.)
            // As this progresses, the Chooses and PropertyGroups are evaluated, so that conditions
            // on Imports involving properties can be evaluated too, because we need to know whether to
            // follow the imports.
            // All this comprises "Pass 1".
            List<XmlElement> childElements = ProjectXmlUtilities.GetValidChildElements(projectElement);

            string currentPerThreadProjectDirectory = Project.PerThreadProjectDirectory;

            try
            {
                // Make the correct project directory available. This is needed because it is 
                // used for evaluating "exists" in conditional expressions, for example on <Import> elements.
                Project.PerThreadProjectDirectory = ProjectDirectory;

                foreach (XmlElement childElement in childElements)
                {
                    switch (childElement.Name)
                    {
                        // Process the <ItemDefinitionGroup> element.
                        case XMakeElements.itemDefinitionGroup:
                            itemDefinitionLibrary.Add(childElement);
                            break;

                        // Process the <ItemGroup> element.
                        case XMakeElements.itemGroup:
                            BuildItemGroup newItemGroup = new BuildItemGroup(childElement, importedProject, /*parent project*/ this);
                            this.rawItemGroups.InsertAtEnd(newItemGroup);
                            break;

                    // Process the <PropertyGroup> element.
                    case XMakeElements.propertyGroup:
                        BuildPropertyGroup newPropertyGroup = new BuildPropertyGroup(this, childElement, importedProject);
                        newPropertyGroup.EnsureNoReservedProperties();
                        this.rawPropertyGroups.InsertAtEnd(newPropertyGroup);
                        // PropertyGroups/Chooses are evaluated immediately during this scan, as they're needed to figure out whether
                        // we include Imports.
                        newPropertyGroup.Evaluate(this.evaluatedProperties, this.conditionedPropertiesTable, ProcessingPass.Pass1);
                        break;

                        // Process the <Choose> element.
                        case XMakeElements.choose:
                            Choose newChoose = new Choose(this, this.rawGroups, childElement, importedProject, 0 /* not nested in another <Choose> */);

                            this.rawGroups.InsertAtEnd(newChoose);
                            // PropertyGroups/Chooses are evaluated immediately during this scan, as they're needed to figure out whether
                            // we include Imports.
                            newChoose.Evaluate(this.evaluatedProperties, false, true, this.conditionedPropertiesTable, ProcessingPass.Pass1);
                            break;

                        // Process the <Target> element.
                        case XMakeElements.target:
                            XmlElement targetElement = childElement;
                            Target newTarget = new Target(targetElement, this, importedProject);

                            // If a target with this name already exists, log a low priority message.
                            if (!ParentEngine.LoggingServices.OnlyLogCriticalEvents)
                            {
                                if (targets.Exists(newTarget.Name))
                                {
                                    ParentEngine.LoggingServices.LogComment(projectBuildEventContext, "OverridingTarget",
                                         targets[newTarget.Name].Name, targets[newTarget.Name].ProjectFileOfTargetElement,
                                         newTarget.Name, newTarget.ProjectFileOfTargetElement);
                                }
                            }

                            this.targets.AddOverrideTarget(newTarget);

                            if (this.nameOfFirstTarget == null)
                            {
                                this.nameOfFirstTarget = targetElement.GetAttribute(XMakeAttributes.name);
                            }
                            break;
//.........这里部分代码省略.........
开发者ID:nikson,项目名称:msbuild,代码行数:101,代码来源:Project.cs

示例2: EvaluateBuildPropertyGroup

		void EvaluateBuildPropertyGroup (BuildPropertyGroup bpg)
		{
			project.PushThisFileProperty (bpg.DefinedInFileName);
			try {
				if (ConditionParser.ParseAndEvaluate (bpg.Condition, project))
					bpg.Evaluate ();
			} finally {
				project.PopThisFileProperty ();
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:GroupingCollection.cs


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