コード例 #1
0
        /// <summary>
        /// 序列化对象
        /// 序列化顺序
        /// 1、类型名
        /// 2、对象的各个属性
        /// </summary>
        /// <param name="serializationStream">流</param>
        /// <param name="graph">对象</param>
        public void Serialize(Stream serializationStream, object graph)
        {
            ILibSerializable     libSerializable = (ILibSerializable)graph;
            LibSerializationInfo sInfo           = new LibSerializationInfo(serializationStream, graph);

            libSerializable.WriteObjectData(sInfo);
        }
コード例 #2
0
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <param name="serializationStream"></param>
        /// <returns></returns>
        public object Deserialize(Stream serializationStream)
        {
            LibSerializationInfo sInfo       = new LibSerializationInfo(serializationStream);
            ILibSerializable     deserialize = sInfo.GetObject();

            deserialize.ReadObjectData(sInfo);
            return(deserialize);
        }