Exemplo n.º 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
                {
                    ProjectUsingTaskParameterElement parameter = ParseUsingTaskParameterElement(childElement, parameterGroup);
                    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);
        }
        /// <summary>
        /// Convenience method that picks a location based on a heuristic:
        /// </summary>
        public ProjectUsingTaskParameterElement AddParameter(string name, string output, string required, string parameterType)
        {
            ErrorUtilities.VerifyThrowArgumentLength(name, "name");

            ProjectUsingTaskParameterElement newParameter = ContainingProject.CreateUsingTaskParameterElement(name, output, required, parameterType);

            AppendChild(newParameter);

            return(newParameter);
        }
        /// <summary>
        /// Creates an unparented UsingTaskParameterElement, wrapping an unparented XmlElement.
        /// Caller should then ensure the element is added to a parent.
        /// </summary>
        internal static ProjectUsingTaskParameterElement CreateDisconnected(string parameterName, string output, string required, string parameterType, ProjectRootElement containingProject)
        {
            XmlUtilities.VerifyThrowArgumentValidElementName(parameterName);
            XmlElementWithLocation           element   = containingProject.CreateElement(parameterName);
            ProjectUsingTaskParameterElement parameter = new ProjectUsingTaskParameterElement(element, containingProject);

            parameter.Output        = output;
            parameter.Required      = required;
            parameter.ParameterType = parameterType;

            return(parameter);
        }
        /// <summary>
        /// Creates an unparented UsingTaskParameterElement, wrapping an unparented XmlElement.
        /// Caller should then ensure the element is added to a parent.
        /// </summary>
        internal static ProjectUsingTaskParameterElement CreateDisconnected(string parameterName, string output, string required, string parameterType, ProjectRootElement containingProject)
        {
            XmlUtilities.VerifyThrowArgumentValidElementName(parameterName);
            XmlElementWithLocation element = containingProject.CreateElement(parameterName);
            ProjectUsingTaskParameterElement parameter = new ProjectUsingTaskParameterElement(element, containingProject);
            parameter.Output = output;
            parameter.Required = required;
            parameter.ParameterType = parameterType;

            return parameter;
        }