private List <double> ReadDoubleList(ByteArray ba) { List <double> tbl = new List <double>(); int len1 = ba.ReadUShort(); ba.ReadUInt(); for (int i = 0; i < len1; i++) { tbl.Add(ReadDouble(ba)); } return(tbl); }
private List <Dictionary <string, object> > ReadDictionaryList(string str, ByteArray ba) { List <Dictionary <string, object> > stbl = new List <Dictionary <string, object> >(); int len1 = ba.ReadUShort(); ba.ReadUInt(); for (int i = 0; i < len1; i++) { stbl.Add(ReadDictionary(str, ba)); } return(stbl); }
private List <int> ReadInt8List(ByteArray ba) { List <int> tbl = new List <int>(); int len1 = ba.ReadUShort(); ba.ReadUInt(); for (int i = 0; i < len1; i++) { int tem_o_read_int = ReadInt8(ba); tbl.Add(tem_o_read_int); } return(tbl); }
private List <bool> ReadBoolList(ByteArray ba) { List <bool> tbl = new List <bool>(); tbl.Clear(); int len1 = ba.ReadUShort(); ba.ReadUInt(); for (int i = 0; i < len1; i++) { tbl.Add(ReadBool(ba)); } return(tbl); }
private List <string> ReadStringList(ByteArray ba) { List <string> tbl = new List <string>(); tbl.Clear(); int len1 = ba.ReadUShort(); ba.ReadUInt(); for (int i = 0; i < len1; i++) { tbl.Add(ReadString(ba)); } return(tbl); }
private Dictionary <string, object> ReadDictionary(string dictName, ByteArray ba) { int fieldType = 0; int repeatType = 0; string fieldName = null; string customType = null; try { int st_len = ba.ReadUInt(); Dictionary <string, object> tbl = new Dictionary <string, object>(); if (st_len == 0) { return(tbl); } List <Dictionary <string, object> > tableInfo = m_protocolInfo[dictName]; for (int i = 0; i < tableInfo.Count; i++) { fieldType = (int)tableInfo[i]["type"]; repeatType = (int)tableInfo[i]["spl"]; fieldName = (string)tableInfo[i]["name"]; if (fieldType == TYPE_string) { if (repeatType == RT_repeated) { tbl[fieldName] = ReadStringList(ba); } else { tbl[fieldName] = ReadString(ba); } } else if (fieldType == TYPE_bool) { if (repeatType == RT_repeated) { tbl[fieldName] = ReadBoolList(ba); } else { tbl[fieldName] = ReadBool(ba); } } else if (fieldType == TYPE_double) { if (repeatType == RT_repeated) { tbl[fieldName] = ReadDoubleList(ba); } else { tbl[fieldName] = ReadDouble(ba); } } else if (fieldType == TYPE_int32) { if (repeatType == RT_repeated) { tbl[fieldName] = ReadIntList(ba); } else { tbl[fieldName] = ReadInt32(ba); } } else if (fieldType == TYPE_int16) { if (repeatType == RT_repeated) { tbl[fieldName] = ReadShortList(ba); } else { tbl[fieldName] = ReadInt16(ba); } } else if (fieldType == TYPE_int8) { if (repeatType == RT_repeated) { tbl[fieldName] = ReadInt8List(ba); } else { tbl[fieldName] = ReadInt8(ba); } } else { customType = (string)tableInfo[i]["vp"]; if (repeatType == RT_repeated) { tbl[fieldName] = ReadDictionaryList(customType, ba); } else { tbl[fieldName] = ReadDictionary(customType, ba); } } } return(tbl); } catch (Exception e) { throw new Exception(@"ReadDictionary Excepiton DictName is ->" + dictName + "<-\nFieldName:->" + fieldName + "<-\nFieldType:->" + GetFieldType(fieldType) + "<-\nRepeatType:->" + GetRepeatType(repeatType) + "<-\nCustomType:->" + customType + "<-\n" + e.ToString()); } }
private int ReadInt(ByteArray ba) { return(ba.ReadUInt()); }