示例#1
0
        private static void Main(String[] args)
        {
            // Create your object
            var input = new POCO
            {
                Cake      = true,
                Vegetable = false,
                Sub       = new SubPOCO
                {
                    SubValue = true
                }
            };

            // Serialize like you normally would
            var payload = LightWeight.Serialize(input);

            // Use the outputted byte array
            Console.WriteLine(BitConverter.ToString(payload));

            // Deserialize like you normally would
            var output = LightWeight.Deserialize <POCO>(payload);
        }
示例#2
0
        /// <summary>
        ///     Deserialize an object from a byte array.
        /// </summary>
        public static T Deserialize <T>(Byte[] payload)
        {
            var lw = new LightWeight();

            return(lw.Decode <T>(payload));
        }
示例#3
0
        /// <summary>
        ///     Serialize an object into a byte array.
        /// </summary>
        public static Byte[] Serialize <T>(T value)
        {
            var lw = new LightWeight();

            return(lw.Encode(value));
        }