System.Xml.Xsl.XmlQueryTypeFactory.AddItemToChoice C# (CSharp) Méthode

AddItemToChoice() private static méthode

Adds itemType to a union. Returns false if new item is a subtype of one of the types in the list.
private static AddItemToChoice ( List accumulator, XmlQueryType itemType ) : void
accumulator List
itemType XmlQueryType
Résultat void
        private static void AddItemToChoice(List<XmlQueryType> accumulator, XmlQueryType itemType) {
            Debug.Assert(itemType.IsSingleton, "All types should be prime.");

            bool addToList = true;
            for (int i = 0; i < accumulator.Count; i++) {
                // If new prime is a subtype of existing prime, don't add it to the union
                if (itemType.IsSubtypeOf(accumulator[i])) {
                    return;
                }

                // If new prime is a subtype of existing prime, then replace the existing prime with new prime
                if (accumulator[i].IsSubtypeOf(itemType)) {
                    if (addToList) {
                        addToList = false;
                        accumulator[i] = itemType;
                    }
                    else {
                        accumulator.RemoveAt(i);
                        i --;
                    }
                }
            }

            if (addToList) {
                accumulator.Add(itemType);
            }
        }