コード例 #1
0
        /// <summary>
        /// Deserializes an object from the XML data in the specified stream.
        /// </summary>
        /// <param name="inStream">The stream containing the XML data.</param>
        /// <returns>The deserialized object.</returns>
        public object Deserialize(Stream inStream)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(inStream);
            XleSerializationInfo info = new XleSerializationInfo(doc);

            info.Binder = Binder;
            return(info.BeginDeserialize());
        }
コード例 #2
0
        /// <summary>
        /// Serializes an object which implements IXleSerializable to the specified stream.
        /// </summary>
        /// <param name="outStream">The stream to write the XML data to.</param>
        /// <param name="objectGraph">The object to serialize.</param>
        public void Serialize(Stream outStream, IXleSerializable objectGraph)
        {
            if (objectType.IsAssignableFrom(objectGraph.GetType()) == false)
            {
                throw new ArgumentException("Object is not of type " + objectType.GetType());
            }

            XleSerializationInfo info = new XleSerializationInfo();

            info.Binder = Binder;
            info.BeginSerialize(objectGraph);

            info.XmlDoc.Save(outStream);
        }