Exemple #1
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.Net45.XmlObjectBase FromXmlStream(System.IO.Stream stream, LiquidTechnologies.Runtime.Net45.XmlSerializationContext context)
 {
     XmlDocument xmlDoc = LiquidTechnologies.Runtime.Net45.XmlObjectBase.LoadXmlDocument(stream, context);
     return FromXmlElement(xmlDoc.DocumentElement, context);
 }
Exemple #2
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.Net45.XmlObjectBase FromXmlElement(XmlElement xmlParent, LiquidTechnologies.Runtime.Net45.XmlSerializationContext context)
        {
            LiquidTechnologies.Runtime.Net45.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.Net45.ClassFactoryHelper.GetElementType(xmlParent) == "")
            {
                elementName = xmlParent.LocalName;
                elementNamespaceUri = xmlParent.NamespaceURI;
            }
            else
            {
                elementName = LiquidTechnologies.Runtime.Net45.ClassFactoryHelper.GetElementType(xmlParent);
                elementNamespaceUri = LiquidTechnologies.Runtime.Net45.ClassFactoryHelper.GetElementTypeNamespaceUri(xmlParent);
            }

            // create the appropriate object
            retVal = LiquidTechnologies.Runtime.Net45.ClassFactoryHelper.CreateObject(_nsMap, elementName, elementNamespaceUri, context);
            if (retVal == null)
                throw new LiquidTechnologies.Runtime.Net45.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;
        }
Exemple #3
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.Net45.XmlObjectBase FromXmlFile(String FileName, LiquidTechnologies.Runtime.Net45.XmlSerializationContext 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);
     }
 }
Exemple #4
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.Net45.XmlObjectBase FromXml(String xmlIn, LiquidTechnologies.Runtime.Net45.XmlSerializationContext context)
 {
     XmlDocument xmlDoc = LiquidTechnologies.Runtime.Net45.XmlObjectBase.LoadXmlDocument(xmlIn, context);
     return FromXmlElement(xmlDoc.DocumentElement, context);
 }