Exemplo n.º 1
0
        // [DebuggerHidden]

        public override void deserializeFromXmlTree(XmlElement nodeNode)
        {
            this.Name = nodeNode.Attributes[MocaTreeUtil.NameAttributeName].InnerXml;
            XmlAttribute indexAttribute = XmlUtil.getXMLAttributeWithName(nodeNode, MocaTreeUtil.IndexAttributeName);

            if (indexAttribute != null)
            {
                Index = int.Parse(indexAttribute.InnerXml) | 0;
            }

            foreach (XmlElement child in nodeNode.ChildNodes)
            {
                if (child.Name == MocaTreeUtil.AttributeNodeDefaultName)
                {
                    MocaAttribute newAttribute = new MocaAttribute();
                    newAttribute.deserializeFromXmlTree(child);
                    this.Attributes.Add(newAttribute);
                    newAttribute.Parent = this;
                }
                else if (child.Name == MocaNode.ChildNodeDefaultName)
                {
                    MocaNode newChild = new MocaNode();
                    newChild.deserializeFromXmlTree(child);
                    this.Children.Add(newChild);
                    newChild.Parent = this;
                }
            }
        }
Exemplo n.º 2
0
        public MocaAttribute appendChildAttribute(String attributeName, String attributeValue)
        {
            MocaAttribute mocaAttribute = null;

            if (attributeValue == null)
            {
                attributeValue = "";
            }

            MocaAttribute existingAttribute = this.getAttribute(attributeName);

            if (existingAttribute != null)
            {
                mocaAttribute       = existingAttribute;
                mocaAttribute.Value = attributeValue;
            }
            else
            {
                mocaAttribute        = new MocaAttribute();
                mocaAttribute.Name   = attributeName;
                mocaAttribute.Parent = this;
                mocaAttribute.Value  = attributeValue;
                this.Attributes.Add(mocaAttribute);
                mocaAttribute.Index = this.Attributes.IndexOf(mocaAttribute);
            }
            return(mocaAttribute);
        }
Exemplo n.º 3
0
        public MocaAttribute getAttributeOrCreate(String attributeName)
        {
            MocaAttribute attribute = getAttribute(attributeName);

            if (attribute == null)
            {
                attribute = this.appendChildAttribute(attributeName, "");
            }

            return(attribute);
        }
Exemplo n.º 4
0
        public MocaAttribute getAttribute(String attributeName)
        {
            MocaAttribute attribute = null;

            foreach (MocaAttribute mocaAttribute in this.Attributes)
            {
                if (mocaAttribute.Name == attributeName)
                {
                    attribute = mocaAttribute;
                }
            }
            return(attribute);
        }
Exemplo n.º 5
0
 public MocaAttribute appendChildAttribute(MocaAttribute attribute)
 {
     return(appendChildAttribute(attribute.Name, attribute.Value));
 }