Beispiel #1
0
        /// <summary>
        /// Process a diff node of xmlschemaelement
        /// </summary>
        /// <param name="rootNode"></param>
        private void CopyChildNodes(XmlSchemaComplexType type, IDiffNode parent, Stack<String> typeStack, bool quickSearch)
        {
            if (type == null || typeStack.Contains(type.Name))
                return;
            typeStack.Push(type.Name);

            IDiffNode idn = null;
            if (currentDiffNodes.TryGetValue(type.ToString(), out idn) && quickSearch)
            {
                // Validator
                typeStack.Pop(); // Pop off
                if (idn.Children != null)
                {
                    foreach (var child in idn.Children)
                        parent.AddChild(child.Clone());
                }
                return;
            }
            else if(quickSearch)
                currentDiffNodes.Add(type.ToString(), parent);

            // Process base content
            if (type.BaseClass != null && type.BaseClass is XmlSchemaComplexType)
                CopyChildNodes(type.BaseClass as XmlSchemaComplexType, parent, typeStack, false);

            foreach (XmlSchemaAttribute att in type.Attributes)
            {
                if (!att.Prohibited && (parent.Children == null || parent.Children.Find(o => o.FriendlyName == att.Name) == null))
                {
                    parent.AddChild(new AttributeDiffNode() { Original = att });
                }
                else if(parent.Children != null) // prohibited use, if it was declared in previous class lets remove it!
                {
                    IDiffNode foundNode = parent.Children.Find(o => o.FriendlyName == att.Name);
                    parent.Children.Remove(foundNode);
                }
            }

            // Process the type
            if (type.Content is XmlSchemaSequence)
                CopyChildNodes(type.Content as XmlSchemaSequence, parent, typeStack);
            else if (type.Content is XmlSchemaChoice)
                CopyChildNodes(type.Content as XmlSchemaChoice, parent, typeStack);

            if (type.Mixed && parent.Children != null && parent.Children.Find(o => o is MixedContentDiffNode) == null)
                parent.AddChild(new MixedContentDiffNode() { Original = type });


            string s = typeStack.Pop();
            System.Diagnostics.Debug.Assert(s.Equals(type.Name));

        }