public static Dictionary <string, DealHeader> GetJsonObject(this DealHeader thdr, IDictionary <string, object> _bag) { Dictionary <string, DealHeader> result = new Dictionary <string, DealHeader>(); IDictionary <string, object> bags = _bag; foreach (KeyValuePair <string, object> bag in bags) { object inst = new object(); IEnumerable <PropertyInfo> map = JsonParser.PrepareInstance(out inst, typeof(DealHeader)); JsonParser.DeserializeType(map, (IDictionary <string, object>)bag.Value, inst); DealHeader deck = (DealHeader)inst; result.Add(bag.Key, deck); } return(result); }
public static Dictionary <string, DealMessage> GetJsonObject(this DealMessage tmsg, string JsonString) { Dictionary <string, DealMessage> result = new Dictionary <string, DealMessage>(); Dictionary <string, object> bags = new Dictionary <string, object>(); tmsg.GetJsonBag(JsonString, bags); foreach (KeyValuePair <string, object> bag in bags) { object inst = new object(); IEnumerable <PropertyInfo> map = JsonParser.PrepareInstance(out inst, typeof(DealMessage)); JsonParser.DeserializeType(map, (IDictionary <string, object>)bag.Value, inst); DealMessage deck = (DealMessage)inst; result.Add(bag.Key, deck); } return(result); }
private bool SrvRecPostDealHeader(ref object array, int objcount) { bool isError = false; string errorMessage = ""; try { DealHeader headerObject = (DealHeader)transaction.MyHeader.Deserialize(ref array, FigureFormat.Json); headerObject.Context.Identity.Ip = transaction.MyHeader.Context.RemoteEndPoint.Address.ToString(); if (DealServer.Security.Register(headerObject.Context.Identity, true)) { transaction.HeaderReceived = (headerObject != null) ? headerObject : null; transaction.MyHeader.Context.Complexity = headerObject.Context.Complexity; transaction.MyHeader.Context.Identity = headerObject.Context.Identity; if (headerObject.Context.ContentType != null) { object instance = new object(); JsonParser.PrepareInstance(out instance, headerObject.Context.ContentType); object content = headerObject.Content; object result = ((IFigureFormatter)instance).Deserialize(ref content, FigureFormat.Json); transaction.HeaderReceived.Content = result; object _content = transaction.HeaderReceived.Content; Type[] ifaces = _content.GetType().GetInterfaces(); if (ifaces.Contains(typeof(IFigureFormatter)) && ifaces.Contains(typeof(IDealSource))) { int objectCount = objcount; object myheader = ((IDealSource)_content).Locate(); //Settings clientConfig = ((ISettings)_content).Config; if (myheader != null) { if (objectCount == 0) { vsspContext.ReceiveMessage = false; //if (clientConfig.DealerId.IsNotEmpty) // transaction.MyHeader.Content = ((IDealSource)myheader).Impact(_content); //else //{ // ((ISettings)myheader).State.Expeled = true; transaction.MyHeader.Content = myheader; // } } else { transaction.MyHeader.Content = ((IDealSource)myheader).Impact(_content); transaction.MessageReceived = new DealMessage(transaction, DirectionType.Receive, transaction.MyHeader.Content); } } else { isError = true; errorMessage += "Prime not exist - incorrect object target "; } } else { isError = true; errorMessage += "Incorrect DPOT object - deserialization error "; } } else { transaction.MyHeader.Content = new Hashtable() { { "Register", true } }; transaction.MyHeader.Context.Echo += "Registration success - ContentType: null "; } } else { isError = true; transaction.MyHeader.Content = new Hashtable() { { "Register", false } }; transaction.MyHeader.Context.Echo += "Registration failed - access denied "; } } catch (Exception ex) { isError = true; errorMessage += ex.ToString(); } if (isError) { transaction.Context.SendMessage = false; if (errorMessage != "") { transaction.MyHeader.Content += errorMessage; transaction.MyHeader.Context.Echo += errorMessage; } transaction.MyHeader.Context.Errors++; } return(isError); }