Beispiel #1
0
        /// <summary>
        /// Parse a UsingTaskParameterGroupElement from the element
        /// </summary>
        private UsingTaskParameterGroupElement ParseUsingTaskParameterGroupElement(XmlElementWithLocation element, ProjectElementContainer parent)
        {
            // There should be no attributes
            ProjectXmlUtilities.VerifyThrowProjectNoAttributes(element);

            UsingTaskParameterGroupElement parameterGroup = new UsingTaskParameterGroupElement(element, parent, _project);

            HashSet <String> listOfChildElementNames = new HashSet <string>();

            foreach (XmlElementWithLocation childElement in ProjectXmlUtilities.GetVerifyThrowProjectChildElements(element))
            {
                // The parameter already exists this means there is a duplicate child item. Throw an exception.
                if (listOfChildElementNames.Contains(childElement.Name))
                {
                    ProjectXmlUtilities.ThrowProjectInvalidChildElementDueToDuplicate(childElement);
                }
                else
                {
                    ProjectXmlUtilities.VerifyThrowProjectAttributes(childElement, ValidAttributesOnUsingTaskParameter);
                    XmlUtilities.VerifyThrowProjectValidElementName(childElement);
                    ProjectUsingTaskParameterElement parameter = new ProjectUsingTaskParameterElement(childElement, parameterGroup, _project);
                    parameterGroup.AppendParentedChildNoChecks(parameter);

                    // Add the name of the child element to the hashset so we can check for a duplicate child element
                    listOfChildElementNames.Add(childElement.Name);
                }
            }

            return(parameterGroup);
        }
Beispiel #2
0
        /// <summary>
        /// Parse a ProjectOtherwiseElement
        /// </summary>
        private ProjectOtherwiseElement ParseProjectOtherwiseElement(XmlElementWithLocation element, ProjectChooseElement parent, int nestingDepth)
        {
            ProjectXmlUtilities.VerifyThrowProjectNoAttributes(element);

            ProjectOtherwiseElement otherwise = new ProjectOtherwiseElement(element, parent, _project);

            ParseWhenOtherwiseChildren(element, otherwise, nestingDepth);

            return(otherwise);
        }
Beispiel #3
0
        /// <summary>
        /// Parse a ProjectExtensionsElement
        /// </summary>
        private ProjectExtensionsElement ParseProjectExtensionsElement(XmlElementWithLocation element)
        {
            // ProjectExtensions are only found in the main project file - in fact, the code used to ignore them in imported
            // files. We don't.
            ProjectXmlUtilities.VerifyThrowProjectNoAttributes(element);

            ProjectErrorUtilities.VerifyThrowInvalidProject(!_seenProjectExtensions, element.Location, "DuplicateProjectExtensions");
            _seenProjectExtensions = true;

            // All children inside ProjectExtensions are ignored, since they are only part of its value
            return(new ProjectExtensionsElement(element, _project, _project));
        }
Beispiel #4
0
        /// <summary>
        /// Parse a ProjectChooseElement
        /// </summary>
        private ProjectChooseElement ParseProjectChooseElement(XmlElementWithLocation element, ProjectElementContainer parent, int nestingDepth)
        {
            ProjectXmlUtilities.VerifyThrowProjectNoAttributes(element);

            ProjectChooseElement choose = new ProjectChooseElement(element, parent, _project);

            nestingDepth++;
            ProjectErrorUtilities.VerifyThrowInvalidProject(nestingDepth <= MaximumChooseNesting, element.Location, "ChooseOverflow", MaximumChooseNesting);

            bool foundWhen      = false;
            bool foundOtherwise = false;

            foreach (XmlElementWithLocation childElement in ProjectXmlUtilities.GetVerifyThrowProjectChildElements(element))
            {
                ProjectElement child = null;

                switch (childElement.Name)
                {
                case XMakeElements.when:
                    ProjectErrorUtilities.VerifyThrowInvalidProject(!foundOtherwise, childElement.Location, "WhenNotAllowedAfterOtherwise");
                    child     = ParseProjectWhenElement(childElement, choose, nestingDepth);
                    foundWhen = true;
                    break;

                case XMakeElements.otherwise:
                    ProjectErrorUtilities.VerifyThrowInvalidProject(!foundOtherwise, childElement.Location, "MultipleOtherwise");
                    foundOtherwise = true;
                    child          = ParseProjectOtherwiseElement(childElement, choose, nestingDepth);
                    break;

                default:
                    ProjectXmlUtilities.ThrowProjectInvalidChildElement(childElement.Name, element.Name, element.Location);
                    break;
                }

                choose.AppendParentedChildNoChecks(child);
            }

            ProjectErrorUtilities.VerifyThrowInvalidProject(foundWhen, element.Location, "ChooseMustContainWhen");

            return(choose);
        }