public T Read(TProtocol protocol) { Object thriftValue = _codec.Read(protocol); T csharpValue = (T)_typeCoercion.FromThrift.DynamicInvoke(thriftValue); return(csharpValue); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }