public DynamicItem(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; } if (valueType == UtilityType.JObjectType) { Content = SerializerUtilitys.Serialize(value.ToString()); } else { Content = SerializerUtilitys.Serialize(value); } }
public DynamicItem(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; } if (valueType == TypeHelper.JObjectType || valueType == TypeHelper.JArrayType) { Content = SerializerUtilitys.Serialize(value.ToString()); } else if (valueType != typeof(CancellationToken)) { Content = SerializerUtilitys.Serialize(value); } }
public byte[] Serialize() { Checkbit = 0x1F; Length = 4 * 3; var bodyArray = SerializerUtilitys.Serialize(Body); Length += bodyArray.Length; return(bodyArray); }
public byte[] Encode(TransportMessage message) { var transportMessage = new MessagePackTransportMessage(message) { Id = message.Id, ContentType = message.ContentType }; return(SerializerUtilitys.Serialize(transportMessage)); }
public ProtoBufTransportMessage(TransportMessage transportMessage) { Id = transportMessage.Id; ContentType = transportMessage.ContentType; if (transportMessage.IsInvokeMessage()) { Content = SerializerUtilitys.Serialize( new ProtoBufRemoteInvokeMessage(transportMessage.GetContent <RemoteInvokeMessage>())); } if (transportMessage.IsResultMessage()) { Content = SerializerUtilitys.Serialize( new ProtoBufRemoteResultMessage(transportMessage.GetContent <RemoteResultMessage>())); } }
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); }