/// <summary> /// Decode each simple type in message. /// </summary> private JsonNode decodeProp(string type, JsonNode proto) { switch (type) { case "uInt32": // TODO: DZÔڵĴíÎó return(new JsonData((int)Decoder.decodeUInt32(this.getBytes()))); case "int32": case "sInt32": return(new JsonData(Decoder.decodeSInt32(this.getBytes()))); case "float": return(new JsonData(this.decodeFloat())); case "double": return(new JsonData(this.decodeDouble())); case "string": return(new JsonData(this.decodeString())); default: return(this.decodeObject(type, proto)); } }
private object decodeProp(string type, int len) { switch (type) { case "uint32": return(Decoder.decodeUInt32(getBytes())); case "int32": case "sint32": return(Decoder.decodeSInt32(getBytes())); case "uint64": return(Decoder.decodeUInt64(getBytes())); case "int64": case "sint64": return(Decoder.decodeSInt64(getBytes())); case "float": return(decodeFloat()); case "double": return(decodeDouble()); case "string": return(decodeString()); case "bool": return(decodeBool()); default: return(decodeObject(type, protos, len)); } }
public static int decodeSInt32(byte[] bytes) { uint num1 = Decoder.decodeUInt32(bytes); int num2 = (int)(num1 % 2U) == 1 ? -1 : 1; return(Convert.ToInt32((long)((num1 % 2U + num1) / 2U) * (long)num2)); }
/// <summary> /// Decode array in message. /// </summary> //private void decodeArray(List<object> list, string type, JsonData 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)); // } // } /// <summary> /// Decode each simple type in message. /// </summary> private object decodeProp(string type, JsonData proto) { switch (type) { case "uInt32": return(Decoder.decodeUInt32(this.getBytes())); case "int32": case "sInt32": return(Decoder.decodeSInt32(this.getBytes())); case "float": //object xx = this.decodeFloat(); //return System.Convert.ToDouble(xx); return(this.decodeFloat()); case "double": return(this.decodeDouble()); case "string": return(this.decodeString()); default: return(this.decodeObject(type, proto)); } }
private uint decodeUInt32() { int length; uint ret = Decoder.decodeUInt32(this.offset, this.buffer, out length); this.offset += length; return(ret); }
//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); }
private string decodeString() { int count = (int)Decoder.decodeUInt32(this.getBytes()); string @string = Encoding.UTF8.GetString(this.buffer, this.offset, count); this.offset += count; return(@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); }
private void decodeArray(JArray list, string type) { uint length = Decoder.decodeUInt32(getBytes()); int curOffset = offset; while (offset < curOffset + length) { list.Add(decodeProp(type, curOffset + Convert.ToInt32(length))); } }
private JsonObject decodeObject(string type, JsonObject proto) { object obj1; object obj2; if (proto == null || !proto.TryGetValue("__messages", out obj1) || !((JsonObject)obj1).TryGetValue(type, out obj2) && !this.protos.TryGetValue("message " + type, out obj2)) { return(new JsonObject()); } int num = (int)Decoder.decodeUInt32(this.getBytes()); return(this.decodeMsg(new JsonObject(), (JsonObject)obj2, this.offset + num)); }
/// <summary> /// Decode array in message. /// </summary> private void decodeArray(List <object> list, string type, JSONNode 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)); } }
private void decodeArray(List <object> list, string type, JsonObject proto) { if (this.util.isSimpleType(type)) { int num = (int)Decoder.decodeUInt32(this.getBytes()); for (int index = 0; index < num; ++index) { list.Add(this.decodeProp(type, (JsonObject)null)); } } else { list.Add(this.decodeProp(type, proto)); } }
private Dictionary <string, int> getHead() { int num = (int)Decoder.decodeUInt32(this.getBytes()); return(new Dictionary <string, int>() { { "type", num & 7 }, { "tag", num >> 3 } }); }
//Decode the user-defined object type in message. private JObject decodeObject(string type, JObject proto, int len) { if (proto == null) { return(new JObject()); } if (len == 0) { len = offset + (int)Decoder.decodeUInt32(getBytes()); } JObject subProto = util.GetProtoMessage(proto, type); JObject msg = new JObject(); return(decodeMsg(msg, subProto, len)); }
//Decode the user-defined object type in message. private JSONNode decodeObject(string type, JSONNode proto) { if (proto != null) { object __messages; if (proto.TryGetValue("__messages", out __messages)) { object _type; if (((JSONNode)__messages).TryGetValue(type, out _type) || protos.TryGetValue("message " + type, out _type)) { int l = (int)Decoder.decodeUInt32(this.getBytes()); JSONNode msg = new JSONClass(); return(this.decodeMsg(msg, (JSONNode)_type, this.offset + l)); } } } return(new JSONClass()); }
//Decode the user-defined object type in message. private JsonNode decodeObject(string type, JsonNode proto) { if (proto != null) { JsonNode __messages = null; if (proto.TryGetValue("__messages", out __messages)) { JsonNode _type = null; if (__messages.TryGetValue(type, out _type) || protos.TryGetValue("message " + type, out _type)) { int l = (int)Decoder.decodeUInt32(this.getBytes()); JsonNode msg = new JsonClass(); return(this.decodeMsg(msg, _type, this.offset + l)); } } } return(new JsonClass()); }
/// <summary> /// Decode each simple type in message. /// </summary> private object decodeProp(string type, JSONNode proto) { switch (type) { case "uInt32": return(Decoder.decodeUInt32(this.getBytes())); case "int32": case "sInt32": return(Decoder.decodeSInt32(this.getBytes())); case "float": return(this.decodeFloat()); case "double": return(this.decodeDouble()); case "string": return(this.decodeString()); default: return(this.decodeObject(type, proto)); } }
public static uint decodeUInt32(byte[] bytes) { int length; return(Decoder.decodeUInt32(0, bytes, out length)); }