Пример #1
0
        public static int SetJson(this DealMessage tmsg, Stream tostream)
        {
            BinaryWriter binwriter = new BinaryWriter(tostream);

            binwriter.Write(tmsg.SetJsonString());
            return((int)tostream.Length);
        }
Пример #2
0
        public static DealMessage GetJson(this DealMessage tmsg, ref object fromarray)
        {
            try
            {
                DealMessage trs = null;
                if (fromarray is String)
                {
                    trs = tmsg.GetJsonObject((String)fromarray)["DealMessage"];
                }
                else
                {
                    byte[]        _fromarray = (byte[])fromarray;
                    StringBuilder sb         = new StringBuilder();

                    sb.Append(_fromarray.ToChars(CharEncoding.UTF8));
                    trs = tmsg.GetJsonObject(sb.ToString())["DealMessage"];

                    fromarray  = null;
                    _fromarray = null;
                    sb         = null;
                }
                return(trs);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #3
0
 public static Dictionary <string, object> SetJsonBag(this DealMessage tmsg)
 {
     return(new Dictionary <string, object>()
     {
         { "DealMessage", JsonParserProperties.GetJsonProperties(typeof(DealMessage))
           .Select(k => new KeyValuePair <string, object>(k.Name, k.GetValue(tmsg, null)))
           .ToDictionary(k => k.Key, v => v.Value) }
     });
 }
Пример #4
0
        public static int SetRaw(this DealMessage bank, Stream tostream)
        {
            if (tostream == null)
            {
                tostream = new MemoryStream();
            }
            BinaryFormatter binform = new BinaryFormatter();

            binform.Serialize(tostream, bank);
            return((int)tostream.Length);
        }
Пример #5
0
 public static DealMessage GetRaw(this DealMessage bank, Stream fromstream)
 {
     try
     {
         BinaryFormatter binform = new BinaryFormatter();
         return((DealMessage)binform.Deserialize(fromstream));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #6
0
 public static DealMessage GetJson(this DealMessage tmsg, string jsonstring)
 {
     try
     {
         DealMessage trs = tmsg.GetJsonObject(jsonstring)["DealMessage"];
         return(trs);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #7
0
 public static DealMessage GetJson(this DealMessage tmsg, StringBuilder stringbuilder)
 {
     try
     {
         StringBuilder sb  = stringbuilder;
         DealMessage   trs = tmsg.GetJsonObject(sb.ToString())["DealMessage"];
         return(trs);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #8
0
        public static int SetRaw(this DealMessage bank, IFigurePacket tostream)
        {
            int          offset = tostream.SerialPacketOffset;
            MemoryStream ms     = new MemoryStream();

            ms.Write(new byte[offset], 0, offset);
            BinaryFormatter binform = new BinaryFormatter();

            binform.Serialize(ms, bank);
            tostream.SerialPacket = ms.ToArray();
            ms.Dispose();
            return(tostream.SerialPacket.Length);
        }
Пример #9
0
        public static Dictionary <string, DealMessage> GetJsonObject(this DealMessage tmsg, IDictionary <string, object> _bag)
        {
            Dictionary <string, DealMessage> result = new Dictionary <string, DealMessage>();
            IDictionary <string, object>     bags   = _bag;

            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);
        }
Пример #10
0
 public static DealMessage GetRaw(this DealMessage bank, ref object fromarray)
 {
     try
     {
         MemoryStream    ms      = new MemoryStream((byte[])fromarray);
         BinaryFormatter binform = new BinaryFormatter();
         DealMessage     _bank   = (DealMessage)binform.Deserialize(ms);
         ms.Dispose();
         return(_bank);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #11
0
        public DealTransfer(MemberIdentity identity, object message = null, ITransferContext context = null)
        {
            Context = context;
            if (Context != null)
            {
                MyHeader = new DealHeader(this, Context, identity);
            }
            else
            {
                MyHeader = new DealHeader(this, identity);
            }

            Identity  = identity;
            Manager   = new TransferManager(this);
            MyMessage = new DealMessage(this, DirectionType.Send, message);
        }
Пример #12
0
 public static DealMessage GetJson(this DealMessage tmsg, Stream fromstream)
 {
     try
     {
         fromstream.Position = 0;
         byte[]        array = new byte[4096];
         int           read  = 0;
         StringBuilder sb    = new StringBuilder();
         while ((read = fromstream.Read(array, 0, array.Length)) > 0)
         {
             sb.Append(array.Cast <char>());
         }
         DealMessage trs = tmsg.GetJsonObject(sb.ToString())["DealMessage"];
         sb = null;
         fromstream.Dispose();
         return(trs);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #13
0
 public DealTransfer()
 {
     MyHeader  = new DealHeader(this);
     Manager   = new TransferManager(this);
     MyMessage = new DealMessage(this, DirectionType.Send, null);
 }
Пример #14
0
 public static void GetJsonBag(this DealMessage tmsg, string JsonString, IDictionary <string, object> _bag)
 {
     _bag.AddRange(JsonParser.FromJson(JsonString));
 }
Пример #15
0
 public static string SetJsonString(this DealMessage tmsg, IDictionary <string, object> jsonbag)
 {
     return(JsonParser.ToJson(jsonbag));
 }
Пример #16
0
        public static string SetJsonString(this DealMessage tmsg)
        {
            IDictionary <string, object> toJson = tmsg.SetJsonBag();

            return(JsonParser.ToJson(toJson));
        }
Пример #17
0
 public static int SetJson(this DealMessage tmsg, IFigurePacket buffor)
 {
     buffor.SerialPacket = Encoding.UTF8.GetBytes(tmsg.SetJsonString());
     return(buffor.SerialPacket.Length);
 }
Пример #18
0
 public static int SetJson(this DealMessage tmsg, StringBuilder stringbuilder)
 {
     stringbuilder.AppendLine(tmsg.SetJsonString());
     return(stringbuilder.Length);
 }