Exemplo n.º 1
0
        public T Read(TProtocol protocol)
        {
            Object thriftValue = _codec.Read(protocol);
            T      csharpValue = (T)_typeCoercion.FromThrift.DynamicInvoke(thriftValue);

            return(csharpValue);
        }
Exemplo n.º 2
0
        public IDictionary <K, V> ReadMapField <K, V>(IThriftCodec <Dictionary <K, V> > mapCodec)
        {
            if (!CheckReadState(TType.Map))
            {
                return(null);
            }
            currentField = null;
            IDictionary <K, V> fieldValue = mapCodec.Read(this.Protocol);

            this.Protocol.ReadFieldEnd();
            return(fieldValue);
        }
Exemplo n.º 3
0
        public List <E> ReadListField <E>(IThriftCodec <List <E> > listCodec)
        {
            if (!CheckReadState(TType.List))
            {
                return(null);
            }
            currentField = null;
            List <E> read = listCodec.Read(this.Protocol);

            Protocol.ReadFieldEnd();
            return(read);
        }
Exemplo n.º 4
0
        public IEnumerable <E> ReadSetField <E>(IThriftCodec <HashSet <E> > setCodec)
        {
            if (!CheckReadState(TType.Set))
            {
                return(null);
            }
            currentField = null;
            IEnumerable <E> fieldValue = setCodec.Read(this.Protocol);

            Protocol.ReadFieldEnd();
            return(fieldValue);
        }
Exemplo n.º 5
0
        public T ReadStructField <T>(IThriftCodec <T> codec)
        {
            if (!CheckReadState(TType.Struct))
            {
                return(default(T));
            }
            currentField = null;
            T fieldValue = codec.Read(this.Protocol);

            Protocol.ReadFieldEnd();
            return(fieldValue);
        }
Exemplo n.º 6
0
        public IList <E> ReadList <E>(IThriftCodec <E> elementCodec)
        {
            TList     tList = Protocol.ReadListBegin();
            IList <E> list  = new List <E>();

            for (int i = 0; i < tList.Count; i++)
            {
                try
                {
                    E element = elementCodec.Read(Protocol);
                    list.Add(element);
                }
                catch (Exception e)
                {
                    // continue
                    e.ThrowIfNecessary();
                }
            }
            Protocol.ReadListEnd();
            return(list);
        }
Exemplo n.º 7
0
        public ISet <E> ReadSet <E>(IThriftCodec <E> elementCodec)
        {
            TSet     tSet = Protocol.ReadSetBegin();
            ISet <E> set  = new HashSet <E>();

            for (int i = 0; i < tSet.Count; i++)
            {
                try
                {
                    E element = elementCodec.Read(Protocol);
                    set.Add(element);
                }
                catch (ArgumentException e)
                {
                    // continue
                    e.ThrowIfNecessary();
                }
            }
            Protocol.ReadSetEnd();
            return(set);
        }
Exemplo n.º 8
0
        public T ReadEnumField <T>(IThriftCodec <T> enumCodec)
            where T : struct
        {
            if (!CheckReadState(TType.I32))
            {
                return(default(T));
            }
            currentField = null;
            T fieldValue = default(T);

            try
            {
                fieldValue = enumCodec.Read(Protocol);
            }
            catch (ArgumentException)
            {
                // return null
            }
            Protocol.ReadFieldEnd();
            return(fieldValue);
        }
Exemplo n.º 9
0
        public IDictionary <K, V> ReadMap <K, V>(IThriftCodec <K> keyCodec, IThriftCodec <V> valueCodec)
        {
            TMap tMap             = Protocol.ReadMapBegin();
            Dictionary <K, V> map = new Dictionary <K, V>();

            for (int i = 0; i < tMap.Count; i++)
            {
                try
                {
                    K key   = keyCodec.Read(this.Protocol);
                    V value = valueCodec.Read(this.Protocol);
                    map[key] = value;
                }
                catch (Exception e)
                {
                    // continue
                    e.ThrowIfNecessary();
                }
            }
            Protocol.ReadMapEnd();
            return(map);
        }