public object Get() { if (Content == null || TypeName == null) { return(null); } var typeName = Type.GetType(TypeName); if (typeName == typeof(JObject)) { var content = SerializerUtilitys.Deserialize <string>(Content); return(JsonConvert.DeserializeObject <JObject>(content)); } else { return(SerializerUtilitys.Deserialize(Content, typeName)); } }
public MessagePackDynamicItem(object value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } var valueType = value.GetType(); var code = Type.GetTypeCode(valueType); if (code != TypeCode.Object && valueType.BaseType != typeof(Enum)) { TypeName = valueType.FullName; } else { TypeName = valueType.AssemblyQualifiedName; } Content = SerializerUtilitys.Serialize(value); }
public ProtoBufferTransportMessage(TransportMessage transportMessage) { Id = transportMessage.Id; ContentType = transportMessage.ContentType; object contentObject; if (transportMessage.IsInvokeMessage()) { contentObject = new ProtoBufferRemoteInvokeMessage(transportMessage.GetContent <RemoteInvokeMessage>()); } else if (transportMessage.IsInvokeResultMessage()) { contentObject = new ProtoBufferRemoteInvokeResultMessage(transportMessage.GetContent <RemoteInvokeResultMessage>()); } else { throw new NotSupportedException($"无法支持的消息类型:{ContentType}!"); } Content = SerializerUtilitys.Serialize(contentObject); }
public ProtoBufferDynamicItem(object value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } var valueType = value.GetType(); var code = Type.GetTypeCode(valueType); //如果是简单类型则取短名称,否则取长名称。 if (code != TypeCode.Object) { TypeName = valueType.FullName; } else { TypeName = valueType.AssemblyQualifiedName; } Content = SerializerUtilitys.Serialize(value); }
public object Get() { if (Content == null || TypeName == null) { return(null); } var typeName = Type.GetType(TypeName); if (typeName == UtilityType.JObjectType || typeName == UtilityType.JArrayType) { var content = SerializerUtilitys.Deserialize <string>(Content); return(JsonConvert.DeserializeObject(content, typeName)); } else if (typeName == null) { var content = SerializerUtilitys.Deserialize <string>(Content); return(content); } else { return(SerializerUtilitys.Deserialize(Content, typeName)); } }
public TransportMessage Decode(byte[] data) { var message = SerializerUtilitys.Deserialize <MessagePackTransportMessage>(data); return(message.GetTransportMessage()); }
public void Deserialize(byte[] data) { Checkbit = 0x1F; Body = SerializerUtilitys.DeSerialize <TMessage>(data); }