Exemple #1
0
Fichier : When.cs Projet : 3F/IeXod
        /// <summary>
        /// Constructor for the When block.  Parses the contents of the When block (property
        /// groups, item groups, and nested chooses) and stores them.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <owner>DavidLe</owner>
        /// <param name="parentProject"></param>
        /// <param name="parentGroupingCollection"></param>
        /// <param name="whenElement"></param>
        /// <param name="importedFromAnotherProject"></param>
        /// <param name="options"></param>
        /// <param name="nestingDepth">stack overflow guard</param>
        internal When(
            Project parentProject,
            GroupingCollection parentGroupingCollection,
            XmlElement whenElement,
            bool importedFromAnotherProject,
            Options options,
            int nestingDepth
            )
        {
            // Make sure the <When> node has been given to us.
            error.VerifyThrow(whenElement != null, "Need valid (non-null) <When> element.");

            // Make sure this really is the <When> node.
            error.VerifyThrow(whenElement.Name == XMakeElements.when || whenElement.Name == XMakeElements.otherwise,
                              "Expected <{0}> or <{1}> element; received <{2}> element.",
                              XMakeElements.when, XMakeElements.otherwise, whenElement.Name);

            this.propertyAndItemLists = new GroupingCollection(parentGroupingCollection);
            this.parentProject        = parentProject;

            string elementName = ((options == Options.ProcessWhen) ? XMakeElements.when : XMakeElements.otherwise);

            if (options == Options.ProcessWhen)
            {
                conditionAttribute = ProjectXmlUtilities.GetConditionAttribute(whenElement, /*verify sole attribute*/ true);
                ProjectErrorUtilities.VerifyThrowInvalidProject(conditionAttribute != null, whenElement, "MissingCondition", XMakeElements.when);
            }
            else
            {
                ProjectXmlUtilities.VerifyThrowProjectNoAttributes(whenElement);
            }

            ProcessWhenChildren(whenElement, parentProject, importedFromAnotherProject, nestingDepth);
        }
Exemple #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="groupingCollection"></param>
 /// <owner>rgoel</owner>
 internal BuildPropertyGroupCollection
 (
     GroupingCollection groupingCollection
 )
 {
     this.groupingCollection = groupingCollection;
 }
Exemple #3
0
 /// <summary>
 /// GroupingCollection constructor.  Basically just initializes internal
 /// data structures.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="parentGroupingCollection">The parent collection of this grouping collection, null for the master collection</param>
 /// <owner>DavidLe</owner>
 /// <returns>IEnumerator</returns>
 internal GroupingCollection
 (
     GroupingCollection parentGroupingCollection
 )
 {
     this.combinedGroupList        = new ArrayList();
     this.parentGroupingCollection = parentGroupingCollection;
 }
Exemple #4
0
        /// <summary>
        /// Constructor that takes the GroupingCollection that this sits over.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <owner>DavidLe</owner>
        /// <param name="groupingCollection"></param>
        internal BuildItemGroupCollection
        (
            GroupingCollection groupingCollection
        )
        {
            error.VerifyThrow(groupingCollection != null, "GroupingCollection is null!");

            this.groupingCollection = groupingCollection;
        }
Exemple #5
0
        /// <summary>
        /// Constructor for the GroupEnumeratorHelper.  At construction
        /// time, you specify the GroupingCollection to use, and the type
        /// of enumerator you wish to get.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <owner>DavidLe</owner>
        /// <param name="groupingCollection"></param>
        /// <param name="type"></param>
        /// <returns>IEnumerator</returns>
        internal GroupEnumeratorHelper
        (
            GroupingCollection groupingCollection,
            ListType type
        )
        {
            error.VerifyThrow(groupingCollection != null, "GroupingCollection is null");

            this.groupingCollection = groupingCollection;
            this.type = type;
        }
Exemple #6
0
        /// <summary>
        /// Constructor for the Choose object.  Parses the contents of the Choose
        /// and sets up list of When blocks
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <owner>DavidLe</owner>
        /// <param name="parentProject"></param>
        /// <param name="parentGroupingCollection"></param>
        /// <param name="chooseElement"></param>
        /// <param name="importedFromAnotherProject"></param>
        /// <param name="nestingDepth">stack overflow guard</param>
        internal Choose
        (
            Project parentProject,
            GroupingCollection parentGroupingCollection,
            XmlElement chooseElement,
            bool importedFromAnotherProject,
            int nestingDepth
        )
        {
            whenClauseList = new ArrayList();

            error.VerifyThrow(chooseElement != null, "Need valid <Choose> element.");

            // Make sure this really is the <Choose> node.
            ProjectXmlUtilities.VerifyThrowElementName(chooseElement, XMakeElements.choose);

            // Stack overflow guard. The only way in the MSBuild file format that MSBuild elements can be
            // legitimately nested without limit is the <Choose> construct. So, enforce a nesting limit
            // to avoid blowing our stack.
            nestingDepth++;
            ProjectErrorUtilities.VerifyThrowInvalidProject(nestingDepth <= maximumChooseNesting, chooseElement, "ChooseOverflow", maximumChooseNesting);

            this.importedFromAnotherProject = importedFromAnotherProject;

            // This <Choose> is coming from an existing XML element, so
            // walk through all the attributes and child elements, creating the
            // necessary When objects.

            // No attributes on the <Choose> element, so don't allow any.
            ProjectXmlUtilities.VerifyThrowProjectNoAttributes(chooseElement);

            bool foundOtherwise = false;

            // Loop through the child nodes of the <Choose> element.
            foreach (XmlNode chooseChildNode in chooseElement)
            {
                switch (chooseChildNode.NodeType)
                {
                // Handle XML comments under the <PropertyGroup> node (just ignore them).
                case XmlNodeType.Comment:
                // fall through
                case XmlNodeType.Whitespace:
                    // ignore whitespace
                    break;

                case XmlNodeType.Element:
                    // The only two types of child nodes that a <Choose> element can contain
                    // is are <When> elements and zero or one <Otherwise> elements.

                    ProjectXmlUtilities.VerifyThrowProjectValidNamespace((XmlElement)chooseChildNode);

                    if (chooseChildNode.Name == XMakeElements.when)
                    {
                        // don't allow <When> to follow <Otherwise>
                        ProjectErrorUtilities.VerifyThrowInvalidProject(!foundOtherwise,
                                                                        chooseChildNode, "WhenNotAllowedAfterOtherwise");
                        When newWhen = new When(parentProject,
                                                parentGroupingCollection,
                                                (XmlElement)chooseChildNode,
                                                importedFromAnotherProject,
                                                When.Options.ProcessWhen,
                                                nestingDepth);
                        this.whenClauseList.Add(newWhen);
                    }
                    else if (chooseChildNode.Name == XMakeElements.otherwise)
                    {
                        ProjectErrorUtilities.VerifyThrowInvalidProject(!foundOtherwise,
                                                                        chooseChildNode, "MultipleOtherwise");
                        When newWhen = new When(parentProject,
                                                parentGroupingCollection,
                                                (XmlElement)chooseChildNode,
                                                importedFromAnotherProject,
                                                When.Options.ProcessOtherwise,
                                                nestingDepth);
                        otherwiseClause = newWhen;
                        foundOtherwise  = true;
                    }
                    else
                    {
                        ProjectXmlUtilities.ThrowProjectInvalidChildElement(chooseChildNode);
                    }
                    break;

                default:
                    // Unrecognized child element.
                    ProjectXmlUtilities.ThrowProjectInvalidChildElement(chooseChildNode);
                    break;
                }
            }
            ProjectErrorUtilities.VerifyThrowInvalidProject(this.whenClauseList.Count != 0,
                                                            chooseElement, "ChooseMustContainWhen");
        }