예제 #1
0
 /// <summary>
 /// Deserialize without create a new object
 /// </summary>
 /// <param name="buffer">Buffer</param>
 /// <param name="type">Type</param>
 /// <param name="settings">Settings</param>
 /// <returns>Object</returns>
 public object Deserialize(byte[] buffer, Type type, BinarySerializerSettings settings = null)
 {
     using (var ms = new MemoryStream(buffer))
     {
         return(Deserialize(ms, type, settings));
     }
 }
예제 #2
0
 /// <summary>
 /// Deserialize
 /// </summary>
 /// <typeparam name="T">Type</typeparam>
 /// <param name="data">Data</param>
 /// <param name="settings">Settings</param>
 /// <returns>Return byte array</returns>
 public T Deserialize <T>(byte[] data, BinarySerializerSettings settings = null)
 {
     using (var ms = new MemoryStream(data))
     {
         return(Deserialize <T>(ms, settings));
     }
 }
예제 #3
0
 /// <summary>
 /// Serialize
 /// </summary>
 /// <param name="obj">Object</param>
 /// <param name="settings">Settings</param>
 /// <returns>Return byte array</returns>
 public byte[] Serialize(object obj, BinarySerializerSettings settings = null)
 {
     using (var ms = new MemoryStream())
     {
         Serialize(obj, ms, settings);
         return(ms.ToArray());
     }
 }
예제 #4
0
        /// <summary>
        /// Serialize
        /// </summary>
        /// <param name="obj">Object</param>
        /// <param name="stream">Stream</param>
        /// <param name="settings">Settings</param>
        /// <returns>Return byte array</returns>
        public int Serialize(object obj, BinaryWriter stream, BinarySerializerSettings settings = null)
        {
            // Search in cache

            if (!BinarySerializerCache.Cache.TryGetValue(obj.GetType(), out var cache))
            {
                throw new NotImplementedException();
            }

            // Serialize

            return(cache.Serialize(this, stream, obj, settings));
        }
예제 #5
0
        /// <summary>
        /// Deserialize
        /// </summary>
        /// <param name="stream">Stream</param>
        /// <param name="type">Type</param>
        /// <param name="settings">Settings</param>
        /// <returns>Return object</returns>
        public object Deserialize(BinaryReader stream, Type type, BinarySerializerSettings settings = null)
        {
            // Search in cache

            if (!BinarySerializerCache.Cache.TryGetValue(type, out var cache))
            {
                throw new KeyNotFoundException("The type is not registered");
            }

            // Deserialize

            return(cache.Deserialize(this, stream, type, settings));
        }
예제 #6
0
        /// <summary>
        /// Serialize
        /// </summary>
        /// <param name="obj">Object</param>
        /// <param name="stream">Stream</param>
        /// <param name="settings">Settings</param>
        /// <returns>Return byte array</returns>
        public int Serialize(object obj, Stream stream, BinarySerializerSettings settings = null)
        {
            // Search in cache

            if (!BinarySerializerCache.Cache.TryGetValue(obj.GetType(), out var cache))
            {
                throw new KeyNotFoundException("The type is not registered");
            }

            // Serialize

            using (var bw = new BinaryWriter(stream, Encoding.UTF8, true))
            {
                return(cache.Serialize(this, bw, obj, settings));
            }
        }
예제 #7
0
        /// <summary>
        /// Deserialize without create a new object
        /// </summary>
        /// <param name="stream">Stream</param>
        /// <param name="type">Type</param>
        /// <param name="settings">Settings</param>
        /// <returns>Object</returns>
        public object Deserialize(Stream stream, Type type, BinarySerializerSettings settings = null)
        {
            // Search in cache

            if (!BinarySerializerCache.Cache.TryGetValue(type, out var cache))
            {
                throw new KeyNotFoundException("The type is not registered");
            }

            // Deserialize

            using (var br = new BinaryReader(stream, Encoding.UTF8, true))
            {
                return(cache.Deserialize(this, br, type, settings));
            }
        }
예제 #8
0
 public int Serialize(object obj, BinaryWriter stream, BinarySerializerSettings settings = null) => BinarySerializer.Default.Serialize(obj, stream, settings);
예제 #9
0
 public byte[] Serialize(object obj, BinarySerializerSettings settings                   = null) => BinarySerializer.Default.Serialize(obj, settings);
예제 #10
0
 public T Deserialize <T>(BinaryReader stream, BinarySerializerSettings settings = null) => BinaryDeserializer.Default.Deserialize <T>(stream, settings);
예제 #11
0
 public T Deserialize <T>(byte[] data, BinarySerializerSettings settings         = null) => BinaryDeserializer.Default.Deserialize <T>(data, settings);
예제 #12
0
 public object Deserialize(BinaryReader stream, Type type, BinarySerializerSettings settings = null) => BinaryDeserializer.Default.Deserialize(stream, type, settings);
예제 #13
0
 public object Deserialize(byte[] data, Type type, BinarySerializerSettings settings         = null) => BinaryDeserializer.Default.Deserialize(data, type, settings);