Beispiel #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);
        }
Beispiel #2
0
        public static List <CFXEnvelope> FromJsonList(string jsonData)
        {
            List <CFXEnvelope> list = CFXJsonSerializer.DeserializeObject <List <CFXEnvelope> >(jsonData);

            foreach (CFXEnvelope env in list)
            {
                Type tp = Type.GetType(env.MessageName);
                env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp);
            }

            return(list);
        }
Beispiel #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);
        }
Beispiel #4
0
        public static List <CFXEnvelope> FromJsonList(string jsonData)
        {
            List <CFXEnvelope> list = CFXJsonSerializer.DeserializeObject <List <CFXEnvelope> >(jsonData);

            foreach (CFXEnvelope env in list)
            {
                // 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) && !string.IsNullOrWhiteSpace(env.messageName))
                {
                    Type tp = Type.GetType(env.messageName);
                    env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp);
                }
            }

            return(list);
        }
Beispiel #5
0
 public static T FromBytes <T>(byte [] data) where T : CFXMessage
 {
     return(CFXJsonSerializer.DeserializeObject <T>(Encoding.UTF8.GetString(data)));
 }
Beispiel #6
0
 public static T FromJson <T>(string jsonData) where T : CFXMessage
 {
     return(CFXJsonSerializer.DeserializeObject <T>(jsonData));
 }