Exemple #1
0
        /// <summary>
        /// Parse a ProjectUsingTaskElement
        /// </summary>
        private ProjectUsingTaskElement ParseProjectUsingTaskElement(XmlElementWithLocation element)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, ValidAttributesOnUsingTask);
            ProjectErrorUtilities.VerifyThrowInvalidProject(element.GetAttribute(XMakeAttributes.taskName).Length > 0, element.Location, "ProjectTaskNameEmpty");

            string assemblyName = element.GetAttribute(XMakeAttributes.assemblyName);
            string assemblyFile = element.GetAttribute(XMakeAttributes.assemblyFile);

            ProjectErrorUtilities.VerifyThrowInvalidProject
            (
                (assemblyName.Length > 0) ^ (assemblyFile.Length > 0),
                element.Location,
                "UsingTaskAssemblySpecification",
                XMakeElements.usingTask,
                XMakeAttributes.assemblyName,
                XMakeAttributes.assemblyFile
            );

            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.assemblyName);
            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.assemblyFile);

            ProjectUsingTaskElement usingTask = new ProjectUsingTaskElement(element, _project, _project);

            bool foundTaskElement    = false;
            bool foundParameterGroup = false;

            foreach (XmlElementWithLocation childElement in ProjectXmlUtilities.GetVerifyThrowProjectChildElements(element))
            {
                ProjectElement child            = null;
                string         childElementName = childElement.Name;
                switch (childElementName)
                {
                case XMakeElements.usingTaskParameterGroup:
                    if (foundParameterGroup)
                    {
                        ProjectXmlUtilities.ThrowProjectInvalidChildElementDueToDuplicate(childElement);
                    }

                    child = ParseUsingTaskParameterGroupElement(childElement, usingTask);
                    foundParameterGroup = true;
                    break;

                case XMakeElements.usingTaskBody:
                    if (foundTaskElement)
                    {
                        ProjectXmlUtilities.ThrowProjectInvalidChildElementDueToDuplicate(childElement);
                    }

                    ProjectXmlUtilities.VerifyThrowProjectAttributes(childElement, ValidAttributesOnUsingTaskBody);

                    child            = new ProjectUsingTaskBodyElement(childElement, usingTask, _project);
                    foundTaskElement = true;
                    break;

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

                usingTask.AppendParentedChildNoChecks(child);
            }

            return(usingTask);
        }
 /// <summary>
 /// Initialize a parented ProjectUsingTaskBodyElement
 /// </summary>
 internal ProjectUsingTaskBodyElement(XmlElementWithLocation xmlElement, ProjectUsingTaskElement parent, ProjectRootElement containingProject)
     : base(xmlElement, parent, containingProject)
 {
     ErrorUtilities.VerifyThrowArgumentNull(parent, nameof(parent));
     VerifyCorrectParent(parent);
 }