Exemplo n.º 1
0
        public void SetObject(FastBinaryFormatter ff, IFastBinarySerializable obj)
        {
            ObjectData = null;
            if (obj == null)
            {
                return;
            }

            ObjectData = ff.Serialize(obj);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the object.
        /// </summary>
        /// <param name="obj">The object.</param>
        public void SetObject(IFastBinarySerializable obj)
        {
            ObjectData = null;
            if (obj == null)
            {
                return;
            }

            using (var ff = new FastBinaryFormatter())
            {
                SetObject(ff, obj);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="additionalInfo">The additional information.</param>
        /// <returns></returns>
        public T GetObject <T>(object additionalInfo) where T : IFastBinarySerializable
        {
            var value = default(T);

            if (ObjectData != null)
            {
                using (var ff = new FastBinaryFormatter())
                {
                    value = GetObject <T>(ff, additionalInfo);
                }
            }

            return(value);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ff">The ff.</param>
        /// <param name="additionalInfo">The additional information.</param>
        /// <returns></returns>
        public T GetObject <T>(FastBinaryFormatter ff, object additionalInfo) where T : IFastBinarySerializable
        {
            T value;

            if (ObjectData != null)
            {
                value = ff.Deserialize <T>(ObjectData, additionalInfo);
            }
            else
            {
                value = default(T);
            }

            return(value);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the object.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="ff">The ff.</param>
 /// <returns></returns>
 public T GetObject <T>(FastBinaryFormatter ff) where T : IFastBinarySerializable
 {
     return(GetObject <T>(ff, null));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FastSerializerObjectData"/> class.
 /// </summary>
 /// <param name="ff">The ff.</param>
 /// <param name="obj">The object.</param>
 public FastSerializerObjectData(FastBinaryFormatter ff, IFastBinarySerializable obj)
 {
     SetObject(ff, obj);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Deserializes the specified formatter.
        /// </summary>
        /// <param name="formatter">The formatter.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static IEnumerable <T> Deserialize(FastBinaryFormatter formatter, byte[] data)
        {
            var serializer = formatter.Deserialize <FastSerializerEnumerable <T> >(data);

            return(serializer.Items);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Deserializes the specified formatter.
        /// </summary>
        /// <param name="formatter">The formatter.</param>
        /// <param name="stream">The stream.</param>
        /// <returns></returns>
        public static IEnumerable <T> Deserialize(FastBinaryFormatter formatter, Stream stream)
        {
            var serializer = formatter.Deserialize <FastSerializerEnumerable <T> >(stream);

            return(serializer.Items);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Serializes the specified formatter.
 /// </summary>
 /// <param name="formatter">The formatter.</param>
 /// <param name="stream">The stream.</param>
 /// <param name="items">The items.</param>
 public static void Serialize(FastBinaryFormatter formatter, Stream stream, IEnumerable <T> items)
 {
     Serialize(formatter, stream, items, null);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Serializes the specified formatter.
        /// </summary>
        /// <param name="formatter">The formatter.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="items">The items.</param>
        /// <param name="additionalInfo">The additional information.</param>
        public static void Serialize(FastBinaryFormatter formatter, Stream stream, IEnumerable <T> items, object additionalInfo)
        {
            var serializer = new FastSerializerEnumerable <T>(items);

            formatter.Serialize(stream, serializer, additionalInfo);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Serializes the specified formatter.
 /// </summary>
 /// <param name="formatter">The formatter.</param>
 /// <param name="items">The items.</param>
 /// <returns></returns>
 public static byte[] Serialize(FastBinaryFormatter formatter, IEnumerable <T> items)
 {
     return(Serialize(formatter, items, null));
 }
Exemplo n.º 12
0
        /// <summary>
        /// Serializes the specified formatter.
        /// </summary>
        /// <param name="formatter">The formatter.</param>
        /// <param name="items">The items.</param>
        /// <param name="additionalInfo">The additional information.</param>
        /// <returns></returns>
        public static byte[] Serialize(FastBinaryFormatter formatter, IEnumerable <T> items, object additionalInfo)
        {
            var serializer = new FastSerializerEnumerable <T>(items);

            return(formatter.Serialize(serializer, additionalInfo));
        }