示例#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));

        }
示例#2
0
        private void CopyChildNodes(XmlSchemaSequence sequence, IDiffNode parent, Stack<String> typeStack)
        {
            if (sequence.Content == null || sequence.Content.Count == 0) return;

            IDiffNode seqNode = parent;

            if (TreatSequenceAsNode)
                seqNode = new SequenceDiffNode()
                {
                    Original = sequence
                };
            // Build the children of this 
            foreach (XmlSchemaObject child in sequence.Content)
                if (child is XmlSchemaChoice)
                    CopyChildNodes(child as XmlSchemaChoice, seqNode, typeStack);
                else if (child is XmlSchemaSequence)
                    CopyChildNodes(child as XmlSchemaSequence, seqNode, typeStack);
                else if (child is XmlSchemaElement)
                    CopyChildNodes(child as XmlSchemaElement, seqNode, typeStack);
                else if (child is XmlSchemaAny)
                    seqNode.AddChild(new DiffNode<XmlSchemaAny>() { Original = child as XmlSchemaAny });

            if (TreatSequenceAsNode)
                parent.AddChild(seqNode);
        }
示例#3
0
        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns></returns>
        public IDiffNode Clone()
        {
            IDiffNode retVal = MemberwiseClone() as IDiffNode;

            if (Children != null)
            {
                retVal.Children = new List <IDiffNode>();
                foreach (var child in Children)
                {
                    retVal.AddChild(child.Clone());
                }
            }

            return(retVal);
        }
示例#4
0
        /// <summary>
        /// Copy element data
        /// </summary>
        private void CopyChildNodes(XmlSchemaElement element, IDiffNode parent, Stack<String> typeStack)
        {
            if (element.MaxOccurs == "0")
            {
                if (parent.Children != null)
                {
                    IDiffNode foundNode = parent.Children.Find(o => o.FriendlyName == element.Name);
                    parent.Children.Remove(foundNode);
                }
                return;
            }
            else if (parent.Children != null &&
                parent.Children.Find(o => o.FriendlyName == element.Name) != null)
                return;

            ElementDiffNode rootNode = new ElementDiffNode() { Original = element };
            if (rootNode.Original.SchemaType is XmlSchemaComplexType)
                CopyChildNodes(rootNode.Original.SchemaType as XmlSchemaComplexType, rootNode, typeStack, true);
            parent.AddChild(rootNode);
        }
示例#5
0
        /// <summary>
        /// Copy child nodes for a choice
        /// </summary>
        private void CopyChildNodes(XmlSchemaChoice choice, IDiffNode parent, Stack<String> typeStack)
        {
            if (choice.Content == null || choice.Content.Count == 0) return;

            ChoiceDiffNode chcNode = new ChoiceDiffNode()
            {
                Original = choice
            };
            // Build the children of this 
            foreach (XmlSchemaObject child in choice.Content)
                if (child is XmlSchemaChoice)
                    CopyChildNodes(child as XmlSchemaChoice, chcNode, typeStack);
                else if (child is XmlSchemaSequence)
                    CopyChildNodes(child as XmlSchemaSequence, chcNode, typeStack);
                else if (child is XmlSchemaElement)
                    CopyChildNodes(child as XmlSchemaElement, chcNode, typeStack);
                else if (child is XmlSchemaAny)
                    chcNode.AddChild(new DiffNode<XmlSchemaAny>() { Original = child as XmlSchemaAny });

            // Don't duplicate on structure
            if (parent.Children == null || FindProbableCandidate(parent.Children, chcNode) == null)
                parent.AddChild(chcNode);
        }