public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); Dictionary <string, object> deserializedJSON = JsonConvert.DeserializeObject <Dictionary <string, object> >(Json); var classType = typeof(ClientSystemStatesNotification); foreach (var keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); if (f == null) { //Client.Log("New Client System State: " + keyPair.Key); continue; } if (keyPair.Value.GetType() == typeof(ArrayList)) { var tempArrayList = keyPair.Value as ArrayList; if (tempArrayList != null && tempArrayList.Count > 0) { f.SetValue(this, tempArrayList.ToArray(f.PropertyType.GetElementType())); } else { f.SetValue(this, null); } } else { f.SetValue(this, keyPair.Value); } } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(Json); Type classType = typeof(ClientSystemStatesNotification); foreach (KeyValuePair <string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); if (f == null) { Client.Log("New Client System State: " + keyPair.Key); continue; } if (keyPair.Value.GetType() == typeof(ArrayList)) { ArrayList tempArrayList = keyPair.Value as ArrayList; if (tempArrayList.Count > 0) { f.SetValue(this, tempArrayList.ToArray(f.PropertyType.GetElementType())); } else { f.SetValue(this, null); } } else { f.SetValue(this, keyPair.Value); } } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); var json = JSONParser.ParseObject(Json, 0); var states = JSONDeserializer.Deserialize <ClientSystemStatesNotification>(json); foreach (PropertyInfo prop in typeof(ClientSystemStatesNotification).GetProperties()) { prop.SetValue(this, prop.GetValue(states)); } //foreach (KeyValuePair<string, object> keyPair in json) { // var f = typeof(ClientSystemStatesNotification).GetProperty(keyPair.Key); // if (f == null) continue; // if (keyPair.Value is MFroehlich.Parsing.JSON.JSONArray) { // var tempArrayList = keyPair.Value as MFroehlich.Parsing.JSON.JSONArray; // if (tempArrayList.Count > 0) { // var array = Array.CreateInstance(f.PropertyType.GetElementType(), tempArrayList.Count); // for (int i = 0; i < tempArrayList.Count; i++) array.SetValue(tempArrayList[i], i); // f.SetValue(this, array); // } else // f.SetValue(this, null); // } else { // f.SetValue(this, (dynamic) keyPair.Value); // } //} }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int) input.ReadUInt32()); var json = JSONParser.ParseObject(Json, 0); if (json.ContainsKey("broadcastMessages")) { BroadcastMessages = JSONDeserializer.Deserialize<List<BroadcastMessage>>(json["broadcastMessages"]); } }
public void ReadExternal(IDataInput input) { this.Json = input.ReadUtf((int)input.ReadUInt32()); Dictionary <string, object> dictionary = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(this.Json); Type type = typeof(BroadcastNotification); foreach (KeyValuePair <string, object> keyValuePair in dictionary) { type.GetProperty(keyValuePair.Key).SetValue((object)this, keyValuePair.Value); } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); var json = JSONParser.ParseObject(Json); if (json.ContainsKey("broadcastMessages")) { BroadcastMessages = JSONDeserializer.Deserialize <List <BroadcastMessage> >(json["broadcastMessages"]); } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); var json = JSONParser.ParseObject(Json); var states = JSONDeserializer.Deserialize <ClientSystemStatesNotification>(json); foreach (PropertyInfo prop in typeof(ClientSystemStatesNotification).GetProperties()) { prop.SetValue(this, prop.GetValue(states)); } }
public void ReadExternal(IDataInput input) { this.Json = input.ReadUtf((int)input.ReadUInt32()); Dictionary <string, object> deserializedJSON = JsonConvert.DeserializeObject <Dictionary <string, object> >(this.Json); Type classType = typeof(BroadcastNotification); foreach (KeyValuePair <string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); //f.SetValue(this, keyPair.Value); } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(Json); Type classType = typeof(ClientSystemStatesNotification); foreach (KeyValuePair <string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); if (keyPair.Value.GetType() == typeof(ArrayList)) { ArrayList tempArrayList = keyPair.Value as ArrayList; if (tempArrayList.Count > 0) { if (Type.GetTypeCode(tempArrayList[0].GetType()) == TypeCode.Int32) { f.SetValue(this, (((ArrayList)keyPair.Value).ToArray(tempArrayList[0].GetType())).Cast <Int32>().ToArray()); } else { f.SetValue(this, ((ArrayList)keyPair.Value).ToArray(tempArrayList[0].GetType())); } } else { f.SetValue(this, null); } /* * ArrayList tempArrayList = keyPair.Value as ArrayList; * if (tempArrayList.Count > 0) * { * Type tempArrayListType = tempArrayList[0].GetType(); * if (tempArrayListType == typeof(Int32)) * Int32[] arr = ((ArrayList)keyPair.Value).ToArray(tempArrayListType).Cast<Int32>().ToArray(); * int[] arr = objarr.Cast<int>().ToArray(); * * f.SetValue(this, arrayList.ToArray(typeof(object))); * } * else * f.SetValue(this, null); */ } else { f.SetValue(this, keyPair.Value); } } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary<string, object> deserializedJSON = serializer.Deserialize<Dictionary<string, object>>(Json); Type classType = typeof(BroadcastNotification); foreach (KeyValuePair<string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); f.SetValue(this, keyPair.Value); } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(Json); Type classType = typeof(BroadcastNotification); foreach (KeyValuePair <string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); f.SetValue(this, keyPair.Value); } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(Json); Type classType = typeof(ClientSystemStatesNotification); foreach (KeyValuePair <string, object> keyPair in deserializedJSON) { try { var f = classType.GetProperty(keyPair.Key); if (f == null) { continue; } if (keyPair.Value.GetType() == typeof(ArrayList)) { ArrayList tempArrayList = keyPair.Value as ArrayList; if (tempArrayList.Count > 0) { f.SetValue(this, ((ArrayList)keyPair.Value).ToArray(tempArrayList[0].GetType())); } else { f.SetValue(this, null); } } else { f.SetValue(this, keyPair.Value); } } catch (Exception e) { Console.WriteLine("Error: {0}", e); } } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); Dictionary <string, object> deserializedJSON = JsonConvert.DeserializeObject <Dictionary <string, object> >(Json); Type classType = typeof(ClientSystemStatesNotification); foreach (KeyValuePair <string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); Type valueType = keyPair.Value.GetType(); if (valueType == typeof(JArray)) { JArray myValue = (JArray)keyPair.Value; if (myValue.Count == 0) //If the array is empty don't try parsing { continue; } if (myValue[0].GetType() != typeof(JValue)) //Don't parse complex arrays { f.SetValue(this, keyPair.Value); continue; } JValue x = (JValue)myValue[0]; Type listType = x.Value.GetType(); Type genericListType = typeof(List <>).MakeGenericType(listType); f.SetValue(this, myValue.ToObject(genericListType)); } else { f.SetValue(this, keyPair.Value); } } }
public void ReadExternal(IDataInput input) { this.Json = input.ReadUtf((int)input.ReadUInt32()); Dictionary <string, object> dictionary = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(this.Json); Type type = typeof(ClientSystemStatesNotification); foreach (KeyValuePair <string, object> keyValuePair in dictionary) { try { PropertyInfo property = type.GetProperty(keyValuePair.Key); if (!(property == (PropertyInfo)null)) { if (keyValuePair.Value.GetType() == typeof(ArrayList)) { ArrayList arrayList = keyValuePair.Value as ArrayList; if (arrayList != null && arrayList.Count > 0) { property.SetValue((object)this, (object)((ArrayList)keyValuePair.Value).ToArray(arrayList[0].GetType())); } else { property.SetValue((object)this, (object)null); } } else { property.SetValue((object)this, keyValuePair.Value); } } } catch (Exception ex) { Console.WriteLine("Error: {0}", (object)ex); } } }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary<string, object> deserializedJSON = serializer.Deserialize<Dictionary<string, object>>(Json); Type classType = typeof(ClientSystemStatesNotification); foreach (KeyValuePair<string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); if (keyPair.Value.GetType() == typeof(ArrayList)) { ArrayList tempArrayList = keyPair.Value as ArrayList; if (tempArrayList.Count > 0) { if (Type.GetTypeCode(tempArrayList[0].GetType()) == TypeCode.Int32) f.SetValue(this, (((ArrayList)keyPair.Value).ToArray(tempArrayList[0].GetType())).Cast<Int32>().ToArray()); else f.SetValue(this, ((ArrayList)keyPair.Value).ToArray(tempArrayList[0].GetType())); } else f.SetValue(this, null); /* ArrayList tempArrayList = keyPair.Value as ArrayList; if (tempArrayList.Count > 0) { Type tempArrayListType = tempArrayList[0].GetType(); if (tempArrayListType == typeof(Int32)) Int32[] arr = ((ArrayList)keyPair.Value).ToArray(tempArrayListType).Cast<Int32>().ToArray(); int[] arr = objarr.Cast<int>().ToArray(); f.SetValue(this, arrayList.ToArray(typeof(object))); } else f.SetValue(this, null); */ } else { f.SetValue(this, keyPair.Value); } } }
public void ReadExternal(IDataInput input) { string str = input.ReadUtf(input.ReadInt32()); this.broadcastMessages = JsonConvert.DeserializeObject<ArrayList>(str); }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int) input.ReadUInt32()); var json = JSONParser.ParseObject(Json, 0); var states = JSONDeserializer.Deserialize<ClientSystemStatesNotification>(json); foreach (PropertyInfo prop in typeof(ClientSystemStatesNotification).GetProperties()) { prop.SetValue(this, prop.GetValue(states)); } //foreach (KeyValuePair<string, object> keyPair in json) { // var f = typeof(ClientSystemStatesNotification).GetProperty(keyPair.Key); // if (f == null) continue; // if (keyPair.Value is MFroehlich.Parsing.JSON.JSONArray) { // var tempArrayList = keyPair.Value as MFroehlich.Parsing.JSON.JSONArray; // if (tempArrayList.Count > 0) { // var array = Array.CreateInstance(f.PropertyType.GetElementType(), tempArrayList.Count); // for (int i = 0; i < tempArrayList.Count; i++) array.SetValue(tempArrayList[i], i); // f.SetValue(this, array); // } else // f.SetValue(this, null); // } else { // f.SetValue(this, (dynamic) keyPair.Value); // } //} }
public void ReadExternal(IDataInput input) { // AbstractMessage int state; PartFlags[] flags = ReadFlags(input); for (int i = 0; i < flags.Length; i++) { state = 0; PartFlags flag = flags[i]; if (i == 0) { if ((flag & PartFlags.BODY_FLAG) != 0) { Body = input.ReadObject(); } else { Body = null; } if ((flag & PartFlags.CLIENT_ID_FLAG) != 0) ClientId = input.ReadObject() as string; if ((flag & PartFlags.DESTINATION_FLAG) != 0) Destination = input.ReadUtf(); if ((flag & PartFlags.HEADERS_FLAG) != 0) Headers = input.ReadObject() as Dictionary<string, object>; if ((flag & PartFlags.MESSAGE_ID_FLAG) != 0) MessageId = input.ReadUtf(); if ((flag & PartFlags.TIMESTAMP_FLAG) != 0) Timestamp = (long)(double)input.ReadObject(); if ((flag & PartFlags.TIME_TO_LIVE_FLAG) != 0) TimeToLive = (long)input.ReadObject(); state = 7; } else if (i == 1) { // clientidbytes if (((int)flag & 0x1) != 0) { clientIdBytes = input.ReadObject() as ByteArray; ClientId = AmfMessageUtils.UIDBytesToString(clientIdBytes.ToArray()); } // messageidbytes if (((int)flag & 0x2) != 0) { messageIdBytes = input.ReadObject() as ByteArray; MessageId = AmfMessageUtils.UIDBytesToString(messageIdBytes.ToArray()); } state = 2; } if (((uint)flag >> state) != 0) { int local6 = state; while (local6 < 6) { if ((((uint)flag >> local6) & 0x1) != 0) { input.ReadObject(); } local6++; } } } ProcessAsyncMessage(input); ProcessAcknowledgeMessage(input); }
public void ReadExternal(IDataInput input) { Json = input.ReadInt32(); this.Data = JObject.Parse(input.ReadUtf(Json)); }
public void ReadExternal(IDataInput input) { Json = input.ReadUtf((int)input.ReadUInt32()); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary<string, object> deserializedJSON = serializer.Deserialize<Dictionary<string, object>>(Json); Type classType = typeof(ClientSystemStatesNotification); foreach (KeyValuePair<string, object> keyPair in deserializedJSON) { var f = classType.GetProperty(keyPair.Key); if (f == null) { Client.Log("New Client System State: " + keyPair.Key); continue; } if (keyPair.Value.GetType() == typeof(ArrayList)) { ArrayList tempArrayList = keyPair.Value as ArrayList; if (tempArrayList.Count > 0) f.SetValue(this, tempArrayList.ToArray(f.PropertyType.GetElementType())); else f.SetValue(this, null); } else { f.SetValue(this, keyPair.Value); } } }
public void ReadExternal(IDataInput input) { string str = input.ReadUtf(input.ReadInt32()); this.broadcastMessages = JsonConvert.DeserializeObject <ArrayList>(str); }