Пример #1
0
        /// <summary>
        ///     Gets or builds a serialization expression tree to convert the specified instance to an array of bytes.
        /// </summary>
        public static byte[] Serialize(object value)
        {
            using (var writer = new StarWriter())
            {
                Serialize(value, writer);

                return(writer.ToArray());
            }
        }
Пример #2
0
        public static void Serialize(object value, StarWriter writer)
        {
            try
            {
                Type type = value.GetType();

                BuildAndStore(type);

                var lambda = PacketSerializers[type];

                lambda(writer, value);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("Serialization error. Type: {0}", value.GetType()), e);
            }
        }
Пример #3
0
 public abstract Task Write(StarWriter writer);