Esempio n. 1
0
        public TransportMessage GetTransportMessage()
        {
            var message = new TransportMessage
            {
                ContentType = ContentType,
                Id          = Id
            };

            object contentObject;

            if (ContentType == TransportMessageType.RemoteInvokeMessage)
            {
                contentObject =
                    SerializerUtilitys.Deserialize <MessagePackRemoteInvokeMessage>(Content).GetMessage();
            }
            else if (ContentType == TransportMessageType.RemoteResultMessage)
            {
                contentObject =
                    SerializerUtilitys.Deserialize <MessagePackRemoteResultMessage>(Content).GetMessage();
            }
            else
            {
                throw new NotSupportedException($"无法支持的消息类型:{ContentType}!");
            }

            message.Content = contentObject;
            return(message);
        }
Esempio n. 2
0
        public TransportMessage GetTransportMessage()
        {
            var message = new TransportMessage
            {
                ContentType = ContentType,
                Id          = Id,
                Content     = null
            };

            object contentObject;

            if (IsInvokeMessage())
            {
                contentObject =
                    SerializerUtilitys.Deserialize <ProtoBufferRemoteInvokeMessage>(Content).GetRemoteInvokeMessage();
            }
            else if (IsInvokeResultMessage())
            {
                contentObject =
                    SerializerUtilitys.Deserialize <ProtoBufferRemoteInvokeResultMessage>(Content)
                    .GetRemoteInvokeResultMessage();
            }
            else
            {
                throw new NotSupportedException($"无法支持的消息类型:{ContentType}!");
            }

            message.Content = contentObject;

            return(message);
        }
Esempio n. 3
0
        public TransportMessage GetTransportMessage(object [] objects)
        {
            var message = new TransportMessage
            {
                ContentType = ContentType,
                Id          = Id,
                Content     = null
            };

            object contentObject;

            if (IsInvokeMessage())
            {
                contentObject =
                    SerializerUtilitys.Deserialize <MessagePackRemoteInvokeMessage>(Content).GetRemoteInvokeMessage();
            }
            else if (IsInvokeResultMessage())
            {
                var resultObj = objects[1] as object[];
                contentObject = new RemoteInvokeResultMessage
                {
                    ExceptionMessage = objects[0] == null ? null : objects[0].ToString(),
                    Result           = resultObj[1].ToString().Substring(1)
                };
            }
            else
            {
                throw new NotSupportedException($"无法支持的消息类型:{ContentType}!");
            }
            message.Content = contentObject;
            return(message);
        }
Esempio n. 4
0
        public object Get()
        {
            if (Content == null || TypeName == null)
            {
                return(null);
            }

            return(SerializerUtilitys.Deserialize(Content, Type.GetType(TypeName)));
        }
Esempio n. 5
0
        public object Get()
        {
            if (Content == null || TypeName == null)
            {
                return(null);
            }
            var typeName     = Type.GetType(TypeName);
            var contenString = SerializerUtilitys.Deserialize <string>(Content);

            return(JsonConvert.DeserializeObject(contenString, typeName));
        }
Esempio n. 6
0
        /// <summary>
        /// Gets this instance.
        /// </summary>
        /// <returns>System.Object.</returns>
        public object Get()
        {
            if (Content == null || TypeName == null)
            {
                return(null);
            }
            var typeName = Type.GetType(TypeName);

            if (typeName == TypeHelper.JObjectType || typeName == TypeHelper.JArrayType)
            {
                var content = SerializerUtilitys.Deserialize <string>(Content);
                return(JsonConvert.DeserializeObject(content, typeName));
            }

            return(SerializerUtilitys.Deserialize(Content, typeName));
        }
Esempio n. 7
0
        public object Get()
        {
            if (Content == null || TypeName == null)
            {
                return(null);
            }
            var typeName = Type.GetType(TypeName);

            if (typeName == UtilityType.JObjectType)
            {
                var content = SerializerUtilitys.Deserialize <string>(Content);
                return(JsonConvert.DeserializeObject <JObject>(content));
            }
            else
            {
                return(SerializerUtilitys.Deserialize(Content, typeName));
            }
        }
Esempio n. 8
0
        public TransportMessage Decode(byte[] data)
        {
            var message = SerializerUtilitys.Deserialize <MessagePackTransportMessage>(data);

            return(message.GetTransportMessage());
        }