Exemplo n.º 1
0
        /// <summary>
        /// Creates an object from an XML Element.
        /// </summary>
        /// <param name="xmlParent">The data that needs loading</param>
        /// <param name="context">The context to use when loading the data</param>
        /// <returns>The wrapper object, loaded with the supplied data</returns>
        /// <remarks>Throws an exception if the XML data is not compatible with the schema</remarks>
        public static LiquidTechnologies.Runtime.Standard20.XmlObjectBase FromXmlElement(XmlElement xmlParent, LiquidTechnologies.Runtime.Standard20.SerializationContext context)
        {
            LiquidTechnologies.Runtime.Standard20.XmlObjectBase retVal = null;
            String elementName;
            String elementNamespaceUri;

            // Get the type name this is either
            // from the element i.e. <Parent>... = Parent
            // or from the type i.e. <Parent xsi:type="someNS:SomeElement">... = SomeElement
            if (LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.GetElementType(xmlParent) == "")
            {
                elementName         = xmlParent.LocalName;
                elementNamespaceUri = xmlParent.NamespaceURI;
            }
            else
            {
                elementName         = LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.GetElementType(xmlParent);
                elementNamespaceUri = LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.GetElementTypeNamespaceUri(xmlParent);
            }

            // create the appropriate object
            retVal = LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.CreateObject(_nsMap, elementName, elementNamespaceUri, context);
            if (retVal == null)
            {
                throw new LiquidTechnologies.Runtime.Standard20.LtException(string.Format("Failed load the element {0}:{1}. No appropriate class exists to load the data into. Ensure that the XML document complies with the schema.", elementName, elementNamespaceUri));
            }

            // load the data into the object
            retVal.FromXmlElement(xmlParent, context);

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an object from XML data held in a stream.
        /// </summary>
        /// <param name="stream">The data to be loaded</param>
        /// <returns>The wrapper object, loaded with the supplied data</returns>
        /// <remarks>Throws an exception if the XML data is not compatible with the schema</remarks>
        public static LiquidTechnologies.Runtime.Standard20.XmlObjectBase FromXmlStream(System.IO.Stream stream, LiquidTechnologies.Runtime.Standard20.SerializationContext context)
        {
            XmlDocument xmlDoc = LiquidTechnologies.Runtime.Standard20.XmlObjectBase.LoadXmlDocument(stream, context);

            return(FromXmlElement(xmlDoc.DocumentElement, context));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an object from XML data held in a string.
        /// </summary>
        /// <param name="xmlIn">The data to be loaded</param>
        /// <param name="context">The context to use when loading the data</param>
        /// <returns>The wrapper object, loaded with the supplied data</returns>
        /// <remarks>Throws an exception if the XML data is not compatible with the schema</remarks>
        public static LiquidTechnologies.Runtime.Standard20.XmlObjectBase FromXml(String xmlIn, LiquidTechnologies.Runtime.Standard20.SerializationContext context)
        {
            XmlDocument xmlDoc = LiquidTechnologies.Runtime.Standard20.XmlObjectBase.LoadXmlDocument(xmlIn, context);

            return(FromXmlElement(xmlDoc.DocumentElement, context));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates an object from XML data held in a File
 /// </summary>
 /// <param name="FileName">The file to be loaded</param>
 /// <param name="context">The context to use when loading the data</param>
 /// <returns>The wrapper object, loaded with the supplied data</returns>
 /// <remarks>Throws an exception if the XML data is not compatible with the schema</remarks>
 public static LiquidTechnologies.Runtime.Standard20.XmlObjectBase FromXmlFile(String FileName, LiquidTechnologies.Runtime.Standard20.SerializationContext context)
 {
     using (System.IO.Stream stream = new System.IO.FileStream(FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
     {
         return(FromXmlStream(stream, context));
     }
 }
Exemplo n.º 5
0
        // We are trying to create a class, however it may be any one of the derived
        // classes that we want, so we need to try to create them, if they fail move on to
        // the next, until we have one that fits.
        public static IReferenceType IReferenceTypeCreateObject(XmlElement xmlParent, LiquidTechnologies.Runtime.Standard20.SerializationContext context)
        {
            Mx.Xml.tns.IReferenceType retVal = null;

            // Get the type name
            String typeName = LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.GetElementType(xmlParent);

            if (typeName == "")
            {
                return(new Mx.Xml.tns.ReferenceType());
            }

            if (retVal == null)
            {
                retVal = LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.CreateObject(_IReferenceTypeMap, typeName, LiquidTechnologies.Runtime.Standard20.ClassFactoryHelper.GetElementTypeNamespaceUri(xmlParent), context) as Mx.Xml.tns.IReferenceType;
            }

            return(retVal);
        }