// Decode the user-defined object type in message. private JsonObject decodeObject(string type, JsonObject proto) { if (proto == null) { return(new JsonObject()); } object __messages; if (proto.TryGetValue("__messages", out __messages) == false) { return(new JsonObject()); } object _type; if (((JsonObject)__messages).TryGetValue(type, out _type) || protos.TryGetValue("message " + type, out _type)) { int l = (int)Decoder.DecodeUInt32(this.GetBytes()); JsonObject msg = new JsonObject(); return(this.DecodeMsg(msg, (JsonObject)_type, this.offset + l)); } return(new JsonObject()); }
// Decode string type. private string DecodeString() { int length = (int)Decoder.DecodeUInt32(this.GetBytes()); string msg_string = Encoding.UTF8.GetString(this.buffer, this.offset, length); this.offset += length; return(msg_string); }
// Get the type and tag. private Dictionary <string, int> GetHead() { int tag = (int)Decoder.DecodeUInt32(this.GetBytes()); Dictionary <string, int> head = new Dictionary <string, int>(); head.Add("type", tag & 0x7); head.Add("tag", tag >> 3); return(head); }
// Decode array in message. private void DecodeArray(List <object> list, string type, JsonObject proto) { if (this.util.IsSimpleType(type)) { int length = (int)Decoder.DecodeUInt32(this.GetBytes()); for (int i = 0; i < length; i++) { list.Add(this.DecodeProp(type, null)); } } else { list.Add(this.DecodeProp(type, proto)); } }