Пример #1
0
        public void SettingWhenConditionDirties()
        {
            string content = @"
                    <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
                        <Choose>
                            <When Condition='true'>
                              <PropertyGroup>
                                <p>v1</p>
                              </PropertyGroup> 
                            </When>      
                        </Choose>
                    </Project>
                ";

            Project project             = new Project(XmlReader.Create(new StringReader(content)));
            ProjectChooseElement choose = Helpers.GetFirst(project.Xml.ChooseElements);
            ProjectWhenElement   when   = Helpers.GetFirst(choose.WhenElements);

            when.Condition = "false";

            Assert.Equal("v1", project.GetPropertyValue("p"));

            project.ReevaluateIfNecessary();

            Assert.Equal(String.Empty, project.GetPropertyValue("p"));
        }
Пример #2
0
        public static void Verify(ProjectWhenElement viewXml, ProjectWhenElement realXml, ValidationContext context = null)
        {
            if (viewXml == null && realXml == null)
            {
                return;
            }
            VerifyProjectElement(viewXml, realXml, context);


            Verify(viewXml.ChooseElements, realXml.ChooseElements, context);
            Verify(viewXml.ItemGroups, realXml.ItemGroups, context);
            Verify(viewXml.PropertyGroups, realXml.PropertyGroups, context);
        }
Пример #3
0
        /// <summary>
        /// Adds a &lt;Choose /&gt; element to the current project.
        /// </summary>
        /// <param name="label">An optional label to add to the Choose.</param>
        /// <returns>The current <see cref="ProjectCreator"/>.</returns>
        public ProjectCreator Choose(string label = null)
        {
            _lastChoose       = AddTopLevelElement(RootElement.CreateChooseElement());
            _lastChoose.Label = label;

            _lastOtherwiseItemGroup     = null;
            _lastOtherwisePropertyGroup = null;
            _lastWhen              = null;
            _lastWhenItemGroup     = null;
            _lastWhenPropertyGroup = null;

            return(this);
        }
Пример #4
0
        /// <summary>
        /// Adds a &lt;When /&gt; element to the current &lt;Choose /&gt; element.
        /// </summary>
        /// <param name="condition">An optional condition to add to the &lt;When /&gt; element.</param>
        /// <param name="label">An optional label to add to the &lt;When /&gt; element.</param>
        /// <returns>The current <see cref="ProjectCreator"/>.</returns>
        public ProjectCreator When(string condition = null, string label = null)
        {
            ProjectChooseElement lastChoose = LastChoose;

            _lastWhen       = RootElement.CreateWhenElement(condition);
            _lastWhen.Label = label;
            lastChoose.AppendChild(_lastWhen);

            _lastWhenPropertyGroup = null;
            _lastWhenItemGroup     = null;

            return(this);
        }