Exemplo n.º 1
0
        public static Packet ToBinary(object value)
        {
            int             length          = SerializedSizeCalculator.Calculate <object>(value);
            SerializeWriter serializeWriter = new SerializeWriter(length, 0);

            SerializeWriterHelper <object, SerializeWriter> .Serialize(ref serializeWriter, value);

            return(serializeWriter.data);
        }
Exemplo n.º 2
0
        public static Packet ToBinary <T>(T value)
        {
            int categoryId = ClassInfo <T> .CategoryId;

            if (categoryId == 0)
            {
                return(SerializeWriter.ToBinary(value));
            }
            int             length          = SerializedSizeCalculator.Calculate <T>(value);
            SerializeWriter serializeWriter = new SerializeWriter(length, categoryId);

            SerializeWriterHelper <T, SerializeWriter> .Serialize(ref serializeWriter, value);

            return(serializeWriter.data);
        }