internal ProjectOnErrorInstance (ProjectOnErrorElement xml)
		{
			condition = xml.Condition;
			ExecuteTargets = xml.ExecuteTargetsAttribute;
			//this.FullPath = fullPath;
			condition_location = xml.ConditionLocation;
			ExecuteTargetsLocation = xml.ExecuteTargetsAttributeLocation;
			location = xml.Location;
		}
        /// <summary>
        /// Creates an unparented ProjectOnErrorElement, wrapping an unparented XmlElement.
        /// Caller should then ensure the element is added to a parent.
        /// </summary>
        internal static ProjectOnErrorElement CreateDisconnected(string executeTargets, ProjectRootElement containingProject)
        {
            XmlElementWithLocation element = containingProject.CreateElement(XMakeElements.onError);

            ProjectOnErrorElement onError = new ProjectOnErrorElement(element, containingProject);

            onError.ExecuteTargetsAttribute = executeTargets;

            return(onError);
        }
        /// <summary>
        /// Creates an unparented ProjectOnErrorElement, wrapping an unparented XmlElement.
        /// Caller should then ensure the element is added to a parent.
        /// </summary>
        internal static ProjectOnErrorElement CreateDisconnected(string executeTargets, ProjectRootElement containingProject)
        {
            XmlElementWithLocation element = containingProject.CreateElement(XMakeElements.onError);

            ProjectOnErrorElement onError = new ProjectOnErrorElement(element, containingProject);

            onError.ExecuteTargetsAttribute = executeTargets;

            return onError;
        }
        internal override ProjectElement LoadChildElement(XmlReader reader)
        {
            switch (reader.LocalName)
            {
            case "OnError":
                var error = new ProjectOnErrorElement(ContainingProject);
                AppendChild(error);
                return(error);

            case "PropertyGroup":
                return(AddPropertyGroup());

            case "ItemGroup":
                return(AddItemGroup());

            default:
                return(AddTask(reader.LocalName));
            }
        }
Exemple #5
0
        /// <summary>
        /// Parse a ProjectTargetElement
        /// </summary>
        private ProjectTargetElement ParseProjectTargetElement(XmlElementWithLocation element)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, s_validAttributesOnTarget);
            ProjectXmlUtilities.VerifyThrowProjectRequiredAttribute(element, XMakeAttributes.name);

            string targetName = ProjectXmlUtilities.GetAttributeValue(element, XMakeAttributes.name);

            // Orcas compat: all target names are automatically unescaped
            targetName = EscapingUtilities.UnescapeAll(targetName);

            int indexOfSpecialCharacter = targetName.IndexOfAny(XMakeElements.illegalTargetNameCharacters);

            if (indexOfSpecialCharacter >= 0)
            {
                ProjectErrorUtilities.ThrowInvalidProject(element.GetAttributeLocation(XMakeAttributes.name), "NameInvalid", targetName, targetName[indexOfSpecialCharacter]);
            }

            ProjectTargetElement  target  = new ProjectTargetElement(element, _project, _project);
            ProjectOnErrorElement onError = null;

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

                switch (childElement.Name)
                {
                case XMakeElements.propertyGroup:
                    if (onError != null)
                    {
                        ProjectErrorUtilities.ThrowInvalidProject(onError.Location, "NodeMustBeLastUnderElement", XMakeElements.onError, XMakeElements.target, childElement.Name);
                    }

                    child = ParseProjectPropertyGroupElement(childElement, target);
                    break;

                case XMakeElements.itemGroup:
                    if (onError != null)
                    {
                        ProjectErrorUtilities.ThrowInvalidProject(onError.Location, "NodeMustBeLastUnderElement", XMakeElements.onError, XMakeElements.target, childElement.Name);
                    }

                    child = ParseProjectItemGroupElement(childElement, target);
                    break;

                case XMakeElements.onError:
                    onError = ParseProjectOnErrorElement(childElement, target);
                    child   = onError;
                    break;

                case XMakeElements.itemDefinitionGroup:
                    ProjectErrorUtilities.ThrowInvalidProject(childElement.Location, "ItemDefinitionGroupNotLegalInsideTarget", childElement.Name);
                    break;

                default:
                    if (onError != null)
                    {
                        ProjectErrorUtilities.ThrowInvalidProject(onError.Location, "NodeMustBeLastUnderElement", XMakeElements.onError, XMakeElements.target, childElement.Name);
                    }

                    child = ParseProjectTaskElement(childElement, target);
                    break;
                }

                target.AppendParentedChildNoChecks(child);
            }

            return(target);
        }
 internal override ProjectElement LoadChildElement (string name)
 {
         switch (name) {
         case "OnError":
                 var error = new ProjectOnErrorElement (ContainingProject);
                 AppendChild (error);
                 return error;
         case "PropertyGroup":
                 return AddPropertyGroup ();
         case "ItemGroup":
                 return AddItemGroup ();
         default:
                 return AddTask (name);
         }
 }