public static void OnEveryEventCallBack(string eventName, IInputEventBase inputEvent) { Dictionary <string, object> tmp = HeapObjectPool.GetSODict(); tmp.Add(c_eventNameKey, inputEvent.GetType().Name); tmp.Add(c_serializeInfoKey, inputEvent.Serialize()); WriteInputEvent(Json.Serialize(tmp)); }
static int GetSODict(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); System.Collections.Generic.Dictionary <string, object> o = HeapObjectPool.GetSODict(); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
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.ReadInt(); Dictionary <string, object> tbl = HeapObjectPool.GetSODict(); 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] = ReadInt(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()); } }
Dictionary <string, object> AnalysisData(string MessageType, byte[] bytes) { string fieldName = ""; string customType = ""; int fieldType = 0; int repeatType = 0; try { Dictionary <string, object> data = HeapObjectPool.GetSODict(); ByteArray ba = HeapObjectPoolTool <ByteArray> .GetHeapObject(); ba.clear(); ba.Add(bytes); string messageTypeTemp = "m_" + MessageType + "_c"; if (!m_protocolInfo.ContainsKey(messageTypeTemp)) { throw new Exception("ProtocolInfo NOT Exist ->" + messageTypeTemp + "<-"); } List <Dictionary <string, object> > tableInfo = m_protocolInfo["m_" + MessageType + "_c"]; 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) { data[fieldName] = ReadStringList(ba); } else { data[fieldName] = ReadString(ba); } } else if (fieldType == TYPE_bool) { if (repeatType == RT_repeated) { data[fieldName] = ReadBoolList(ba); } else { data[fieldName] = ReadBool(ba); } } else if (fieldType == TYPE_double) { if (repeatType == RT_repeated) { data[fieldName] = ReadDoubleList(ba); } else { data[fieldName] = ReadDouble(ba); } } else if (fieldType == TYPE_int32) { if (repeatType == RT_repeated) { data[fieldName] = ReadIntList(ba); } else { data[fieldName] = ReadInt(ba); } } else { customType = (string)tableInfo[i]["vp"]; if (repeatType == RT_repeated) { data[fieldName] = ReadDictionaryList(customType, ba); } else { data[fieldName] = ReadDictionary(customType, ba); } } } return(data); } catch (Exception e) { throw new Exception(@"AnalysisData Excepiton Data is ->" + MessageType + "<-\nFieldName:->" + fieldName + "<-\nFieldType:->" + GetFieldType(fieldType) + "<-\nRepeatType:->" + GetRepeatType(repeatType) + "<-\nCustomType:->" + customType + "<-\n" + e.ToString()); } }