コード例 #1
0
ファイル: XleSerializer.cs プロジェクト: eylvisaker/Xle
        /// <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.GetTypeInfo().IsAssignableFrom(objectGraph.GetType().GetTypeInfo()) == false)
            {
                throw new ArgumentException("Object is not of type " + objectType.Name);
            }

            XleSerializationInfo info = new XleSerializationInfo(Binder, TypeSerializers);

            info.BeginSerialize(objectGraph);

            info.XmlDoc.Save(outStream);
        }