/// <summary> /// Removes a Choose block from the list. This method does nothing to manipulate /// the project's XML content. /// </summary> /// <remarks> /// </remarks> /// <owner>DavidLe</owner> /// <param name="choose"></param> internal void RemoveChoose ( Choose choose ) { error.VerifyThrow(this.combinedGroupList != null, "Arraylist not initialized!"); this.combinedGroupList.Remove(choose); this.chooseCount--; error.VerifyThrow(this.chooseCount >= 0, "Too many calls to RemoveChoose()."); }
/// <summary> /// Returns an enumerator into the GroupingCollection specified /// at instantiation time. /// </summary> /// <remarks> /// </remarks> /// <owner>DavidLe</owner> /// <returns>IEnumerator</returns> public IEnumerator GetEnumerator( ) { foreach (IItemPropertyGrouping group in this.groupingCollection) { if ((group is BuildItemGroup) && ((this.type == ListType.ItemGroupsTopLevel) || (this.type == ListType.ItemGroupsTopLevelAndChoose) || (this.type == ListType.ItemGroupsAll))) { yield return(group); } else if ((group is BuildPropertyGroup) && ((this.type == ListType.PropertyGroupsTopLevel) || (this.type == ListType.PropertyGroupsTopLevelAndChoose) || (this.type == ListType.PropertyGroupsAll))) { yield return(group); } else if (group is Choose) { if ((this.type == ListType.ChoosesTopLevel) || (this.type == ListType.ItemGroupsTopLevelAndChoose) || (this.type == ListType.PropertyGroupsTopLevelAndChoose)) { yield return(group); } // Recurse into Choose groups to find all item/property groups else if ((this.type == ListType.ItemGroupsAll) || (this.type == ListType.PropertyGroupsAll)) { Choose choose = (Choose)group; foreach (When when in choose.Whens) { if (this.type == ListType.ItemGroupsAll) { foreach (IItemPropertyGrouping nestedGroup in when.PropertyAndItemLists.ItemGroupsAll) { yield return(nestedGroup); } } else if (this.type == ListType.PropertyGroupsAll) { foreach (IItemPropertyGrouping nestedGroup in when.PropertyAndItemLists.PropertyGroupsAll) { yield return(nestedGroup); } } } if (choose.Otherwise != null) { if (this.type == ListType.ItemGroupsAll) { foreach (IItemPropertyGrouping nestedGroup in choose.Otherwise.PropertyAndItemLists.ItemGroupsAll) { yield return(nestedGroup); } } else if (this.type == ListType.PropertyGroupsAll) { foreach (IItemPropertyGrouping nestedGroup in choose.Otherwise.PropertyAndItemLists.PropertyGroupsAll) { yield return(nestedGroup); } } } } } } }
/// <summary> /// Helper method for processing the children of a When. Only parses Choose, /// PropertyGroup, and ItemGroup. All other tags result in an error. /// </summary> /// <remarks> /// </remarks> /// <owner>DavidLe</owner> /// <param name="parentNode"></param> /// <param name="parentProjectForChildren"></param> /// <param name="importedFromAnotherProject"></param> /// <param name="options"></param> /// <param name="nestingDepth">Number of parent <Choose> elements this is nested inside</param> private void ProcessWhenChildren ( XmlElement parentNode, Project parentProjectForChildren, bool importedFromAnotherProject, int nestingDepth ) { // Loop through the child nodes of the <When> element. foreach (XmlNode whenChildNode in parentNode) { switch (whenChildNode.NodeType) { // Handle XML comments under the <When> node (just ignore them). case XmlNodeType.Comment: // fall through case XmlNodeType.Whitespace: // ignore whitespace break; case XmlNodeType.Element: { // Make sure this element doesn't have a custom namespace ProjectXmlUtilities.VerifyThrowProjectValidNamespace((XmlElement)whenChildNode); // The only three types of child nodes that a <When> element can contain // are <PropertyGroup>, <ItemGroup> and <Choose>. switch (whenChildNode.Name) { case XMakeElements.itemGroup: BuildItemGroup newItemGroup = new BuildItemGroup((XmlElement)whenChildNode, importedFromAnotherProject, parentProjectForChildren); this.propertyAndItemLists.InsertAtEnd(newItemGroup); break; // Process the <PropertyGroup> element. case XMakeElements.propertyGroup: BuildPropertyGroup newPropertyGroup = new BuildPropertyGroup(parentProjectForChildren, (XmlElement)whenChildNode, importedFromAnotherProject); newPropertyGroup.EnsureNoReservedProperties(); this.propertyAndItemLists.InsertAtEnd(newPropertyGroup); break; // Process the <Choose> element. case XMakeElements.choose: Choose newChoose = new Choose(parentProjectForChildren, this.PropertyAndItemLists, (XmlElement)whenChildNode, importedFromAnotherProject, nestingDepth); this.propertyAndItemLists.InsertAtEnd(newChoose); break; default: { ProjectXmlUtilities.ThrowProjectInvalidChildElement(whenChildNode); break; } } } break; default: { ProjectXmlUtilities.ThrowProjectInvalidChildElement(whenChildNode); break; } } } }