Example #1
0
            public T Decode<T>()
            {
                if (_codec._multicodec)
                    Multicodec.ConsumeHeader(_stream, _codec.Header);

                var bytes = MessageIo.ReadMessage(_stream);

                return (T)(object)bytes;
            }
Example #2
0
            public T Decode <T>()
            {
                if (_codec._multicodec)
                {
                    Multicodec.ConsumeHeader(_stream, _codec.Header);
                }

                if (_codec._msgio)
                {
                    return(Deserialize <T>(MessageIo.ReadMessage(_stream)));
                }

                return(ProtoBuf.Serializer.DeserializeWithLengthPrefix <T>(_stream, PrefixStyle.Fixed32BigEndian));
            }
Example #3
0
            public T Decode<T>()
            {
                if (_codec._multicodec)
                    Multicodec.ConsumeHeader(_stream, _codec.Header);

                var json = string.Empty;
                if (_codec._msgio)
                {
                    var bytes = MessageIo.ReadMessage(_stream);
                    json = Encoding.UTF8.GetString(bytes);
                }
                else
                {
                    json = ReadLine(_stream);
                }

                return JsonConvert.DeserializeObject<T>(json);

            }