Ejemplo n.º 1
0
        /// <summary> Encodes a Composite in XML by looping through it's components, creating new
        /// children for each of them (with the appropriate names) and populating them by
        /// calling encode(Type, Element) using these children.  Returns true if at least
        /// one component contains a value.
        /// </summary>
        private bool encodeComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            Type[] components = datatypeObject.Components;
            bool   hasValue   = false;

            for (int i = 0; i < components.Length; i++)
            {
                System.String         name    = makeElementName(datatypeObject, i + 1);
                System.Xml.XmlElement newNode = datatypeElement.OwnerDocument.CreateElement(name);
                bool componentHasValue        = encode(components[i], newNode);
                if (componentHasValue)
                {
                    try
                    {
                        datatypeElement.AppendChild(newNode);
                    }
                    //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    catch (System.Exception e)
                    {
                        throw new DataTypeException("DOMException encoding Composite: ", e);
                    }
                    hasValue = true;
                }
            }
            return(hasValue);
        }
Ejemplo n.º 2
0
 /// <summary> Populates a Composite type by looping through it's children, finding corresponding
 /// Elements among the children of the given Element, and calling parse(Type, Element) for
 /// each.
 /// </summary>
 private void  parseComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement)
 {
     if (datatypeObject is GenericComposite)
     {
         //elements won't be named GenericComposite.x
         //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
         System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
         int compNum = 0;
         for (int i = 0; i < children.Count; i++)
         {
             if (System.Convert.ToInt16(children.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element)
             {
                 parse(datatypeObject.getComponent(compNum), (System.Xml.XmlElement)children.Item(i));
                 compNum++;
             }
         }
     }
     else
     {
         Type[] children = datatypeObject.Components;
         for (int i = 0; i < children.Length; i++)
         {
             System.Xml.XmlNodeList matchingElements = datatypeElement.GetElementsByTagName(makeElementName(datatypeObject, i + 1));
             if (matchingElements.Count > 0)
             {
                 parse(children[i], (System.Xml.XmlElement)matchingElements.Item(0));                          //components don't repeat - use 1st
             }
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>Returns the expected XML element name for the given child of the given Composite </summary>
 private System.String makeElementName(Composite composite, int child)
 {
     return(composite.TypeName + "." + child);
 }
Ejemplo n.º 4
0
 /// <summary> Populates a Composite type by looping through it's children, finding corresponding 
 /// Elements among the children of the given Element, and calling parse(Type, Element) for
 /// each.
 /// </summary>
 private void parseComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement)
 {
     if (datatypeObject is GenericComposite)
     {
         //elements won't be named GenericComposite.x
         //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
         System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
         int compNum = 0;
         for (int i = 0; i < children.Count; i++)
         {
             if (System.Convert.ToInt16(children.Item(i).NodeType) == (short) System.Xml.XmlNodeType.Element)
             {
                 parse(datatypeObject.getComponent(compNum), (System.Xml.XmlElement) children.Item(i));
                 compNum++;
             }
         }
     }
     else
     {
         Type[] children = datatypeObject.Components;
         for (int i = 0; i < children.Length; i++)
         {
             System.Xml.XmlNodeList matchingElements = datatypeElement.GetElementsByTagName(makeElementName(datatypeObject, i + 1));
             if (matchingElements.Count > 0)
             {
                 parse(children[i], (System.Xml.XmlElement) matchingElements.Item(0)); //components don't repeat - use 1st
             }
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>Returns the expected XML element name for the given child of the given Composite </summary>
 private System.String makeElementName(Composite composite, int child)
 {
     return composite.TypeName + "." + child;
 }
Ejemplo n.º 6
0
 /// <summary> Encodes a Composite in XML by looping through it's components, creating new 
 /// children for each of them (with the appropriate names) and populating them by 
 /// calling encode(Type, Element) using these children.  Returns true if at least 
 /// one component contains a value.  
 /// </summary>
 private bool encodeComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement)
 {
     Type[] components = datatypeObject.Components;
     bool hasValue = false;
     for (int i = 0; i < components.Length; i++)
     {
         System.String name = makeElementName(datatypeObject, i + 1);
         System.Xml.XmlElement newNode = datatypeElement.OwnerDocument.CreateElement(name);
         bool componentHasValue = encode(components[i], newNode);
         if (componentHasValue)
         {
             try
             {
                 datatypeElement.AppendChild(newNode);
             }
                 //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
             catch (System.Exception e)
             {
                 throw new DataTypeException("DOMException encoding Composite: ", e);
             }
             hasValue = true;
         }
     }
     return hasValue;
 }