コード例 #1
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);
        }
コード例 #2
0
        protected override ProjectElement CreateChildElement(string name)
        {
            switch (name)
            {
            case "When":
                var when = RootElement.CreateWhenElement(null);
                PrependChild(when);
                return(when);

            case "Otherwise":
                var other = RootElement.CreateOtherwiseElement();
                AppendChild(other);
                return(other);

            default:
                throw new InvalidOperationException(String.Format(
                                                        "Child \"{0}\" is not a known node type.", name));
            }
        }
コード例 #3
0
        protected override ProjectElement CreateChildElement(string name)
        {
            switch (name)
            {
            case "PropertyGroup":
                var property = RootElement.CreatePropertyGroupElement();
                AppendChild(property);
                return(property);

            case "ItemGroup":
                var item = RootElement.CreateItemGroupElement();
                AppendChild(item);
                return(item);

            case "When":
                var when = RootElement.CreateWhenElement(null);
                AppendChild(when);
                return(when);

            default:
                throw new InvalidProjectFileException(String.Format(
                                                          "Child \"{0}\" is not a known node type.", name));
            }
        }