Beispiel #1
0
        public T Decode <T>(ArraySegment <Byte> input)
        {
#if DEBUG
            if (null == input)
            {
                throw new ArgumentNullException(nameof(input));
            }
#endif

            // Assume root is a class
            var coder = new HeliumClass(0, false);
            coder.Prepare(typeof(T));

            // Invoke root serializer
            var value = coder.Decode(new DecodeBuffer(input));
            return((T)value);
        }
Beispiel #2
0
        public Byte[] Encode <T>(T value)
        {
#if DEBUG
            if (null == value)
            {
                throw new ArgumentNullException(nameof(value));
            }
#endif

            // Assume root is a class
            var coder = new HeliumClass(0, false);
            coder.Prepare(typeof(T));

            // Invoke coder
            var output = coder.Encode(value);

            // Flattern into to byte array
            return(output.Flattern());
        }