Ejemplo n.º 1
0
        internal void Serialize(Stream stream, object graph)
        {
            int          size   = ObjectBufferSerializer.GetSize(this, graph);
            ObjectWriter buffer = new ObjectWriter(size);

            Serializer(buffer, graph);
            stream.Write(buffer.GetBuffer(), 0, buffer.position);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 计算对象的内存占用情况
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static long Sizeof(object value)
 {
     return(ObjectBufferSerializer.Sizeof(value));
 }
Ejemplo n.º 3
0
        public static object BinaryDeserialize(byte[] buffer, Type type)
        {
            ObjectReader stream = new ObjectReader(buffer);

            return(ObjectBufferSerializer.Deserialize(stream, type));
        }
Ejemplo n.º 4
0
        public static T BinaryDeserialize <T>(byte[] buffer)
        {
            ObjectReader stream = new ObjectReader(buffer);

            return(ObjectBufferSerializer.Deserialize <T>(stream));
        }
Ejemplo n.º 5
0
 public static void BinarySerialize(Stream stream, object graph)
 {
     ObjectBufferSerializer.Serialize(stream, graph);
 }
Ejemplo n.º 6
0
        //public static T Deserialize<T>(string value, SerializerSettings settings) where T : class
        //{
        //    throw new Exception("Not supported,it will implementation in next versions");
        //}

        //public static T FromJson<T>(this string json) where T : class
        //{
        //    //return Deserialize<T>(new JsonStream());
        //    throw new Exception("Not supported,it will implementation in next versions");
        //}

        #endregion

        #region Bin Serialize

        /// <summary>
        /// 序列化成二进制数据
        /// </summary>
        /// <param name="graph"></param>
        /// <returns></returns>
        public static byte[] BinarySerialize(object graph)
        {
            return(ObjectBufferSerializer.Serialize(graph));
        }