Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 4
0
        public object Get()
        {
            if (Content == null || TypeName == null)
            {
                return(null);
            }

            return(SerializerUtilitys.Deserialize(Content, Type.GetType(TypeName)));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
            }
        }
Exemplo n.º 8
0
        public TransportMessage Decode(byte[] data)
        {
            var message = SerializerUtilitys.Deserialize <MessagePackTransportMessage>(data);

            return(message.GetTransportMessage());
        }