示例#1
0
        public static CFXEnvelope FromJson(string jsonData)
        {
            CFXEnvelope env = CFXJsonSerializer.DeserializeObject <CFXEnvelope>(jsonData);
            Type        tp  = Type.GetType(env.MessageName);

            env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp);
            return(env);
        }
示例#2
0
 private void TheEndpoint_OnCFXMessageReceived(AmqpChannelAddress source, CFX.CFXEnvelope message)
 {
     this.BeginInvoke(((Action)(() =>
     {
         message.ToJson().Split(new string[] { "\r\n" }, StringSplitOptions.None).Reverse().ToList().ForEach(s => lstResults.Items.Insert(0, s));
         while (lstResults.Items.Count > maxResults)
         {
             lstResults.Items.RemoveAt(maxResults);
         }
     })));
 }
示例#3
0
        public static CFXEnvelope FromJson(string jsonData)
        {
            CFXEnvelope env = CFXJsonSerializer.DeserializeObject <CFXEnvelope>(jsonData);

            // For backwards compatibility.  Older versions of the SDK did not properly decorate the $type of the MessageBody property,
            // so the message portion had to be deserialized individually, which was inefficient.
            if (!(env.MessageBody is CFXMessage))
            {
                Type tp = Type.GetType(env.MessageName);
                env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp);
            }

            return(env);
        }
示例#4
0
        internal static CFXEnvelope ReadRecord(BinaryReader reader)
        {
            try
            {
                long        filePosition = reader.BaseStream.Position;
                bool        transmitted  = reader.ReadBoolean();
                Int32       len          = reader.ReadInt32();
                byte[]      data         = reader.ReadBytes(len);
                CFXEnvelope result       = FromBytes(data);
                result.QueueFilePosition = filePosition;
                result.Transmitted       = transmitted;
                return(result);
            }
            catch (Exception ex)
            {
                AppLog.Error(ex);
            }

            return(null);
        }
示例#5
0
 public static CFXEnvelope FromBytes(byte[] data)
 {
     return(CFXEnvelope.FromJson(Encoding.UTF8.GetString(data)));
 }