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); }
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); }
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); }
public object Get() { if (Content == null || TypeName == null) { return(null); } return(SerializerUtilitys.Deserialize(Content, Type.GetType(TypeName))); }
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)); }
/// <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)); }
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)); } }
public TransportMessage Decode(byte[] data) { var message = SerializerUtilitys.Deserialize <MessagePackTransportMessage>(data); return(message.GetTransportMessage()); }