public static T DeserializeObject <T>(HGlobalCache <byte> hGCache, MessagePackFormatterOptions options) { unsafe { return(DeserializeObject <T>(hGCache.First, hGCache.Count, options)); } }
void DeserializeTo <TMode>(byte *bytes, int length, IDataWriter dataWriter, MessagePackFormatterOptions options) where TMode : struct { var deserializer = new MessagePackDeserializer <TMode>(this, bytes, length, MaxDepth, options); if (typeof(TMode) == typeof(MessagePackDeserializeModes.ReferenceMode)) { deserializer.InitReferences(); } switch (deserializer.GetToken()) { case MessagePackToken.Map: if (dataWriter is IDataWriter <string> objectWriter) { deserializer.InternalReadObject(objectWriter); } else { ((IAsDataWriter)dataWriter.As <string>()).InvokeTIn(new MessagePackDeserializer <TMode> .InternalWriteMapInvoker(deserializer, dataWriter)); } break; case MessagePackToken.Array: deserializer.InternalReadArray(dataWriter.As <int>()); break; default: dataWriter.Content = XConvert.Cast(deserializer.DirectRead(), dataWriter.ContentType); break; } }
public static object DeserializeObject(byte[] bytes, Type type, MessagePackFormatterOptions options) { unsafe { fixed(byte *pBytes = bytes) { return(DeserializeObject(pBytes, bytes.Length, type, options)); } } }
public static T DeserializeObject <T>(ReadOnlySpan <byte> bytes, MessagePackFormatterOptions options) { unsafe { fixed(byte *pBytes = bytes) { return(DeserializeObject <T>(pBytes, bytes.Length, options)); } } }
public static T DeserializeObject <T>(ArraySegment <byte> bytes, MessagePackFormatterOptions options) { unsafe { fixed(byte *pBytes = &bytes.Array[bytes.Offset]) { return(DeserializeObject <T>(pBytes, bytes.Count, options)); } } }
public MessagePackSerializer( MessagePackFormatterOptions options, int maxDepth, HGlobalCache <byte> hGlobal, MessagePackForamtter foramtter, Stream stream) : this(options, maxDepth, hGlobal) { MessagePackForamtter = foramtter; Stream = stream; }
public static void SerializeObject <T>(T value, HGlobalCache <byte> hGCache, MessagePackFormatterOptions options) { if ((options & ReferenceSerializerOptions) != 0) { SerializeObject <T, MessagePackSerializeModes.ReferenceMode>(value, hGCache, options); } else { SerializeObject <T, MessagePackSerializeModes.StandardMode>(value, hGCache, options); } }
object Deserialize <TMode>(byte *bytes, int length, Type type, MessagePackFormatterOptions options) where TMode : struct { var deserializer = new MessagePackDeserializer <TMode>(this, bytes, length, MaxDepth, options); if (typeof(TMode) == typeof(MessagePackDeserializeModes.ReferenceMode)) { deserializer.InitReferences(); } return(ValueInterface.GetInterface(type).Read(deserializer)); }
static object DeserializeObject(byte *bytes, int length, Type type, MessagePackFormatterOptions options) { if ((options & ReferenceDeserializerOptions) != 0) { return(DeserializeObject <MessagePackDeserializeModes.ReferenceMode>(bytes, length, type, options)); } else { return(DeserializeObject <MessagePackDeserializeModes.StandardMode>(bytes, length, type, options)); } }
static T DeserializeObject <T, TMode>(byte *bytes, int length, MessagePackFormatterOptions options) where TMode : struct { var deserializer = new MessagePackDeserializer <TMode>(bytes, length, DefaultMaxDepth, options); if (typeof(TMode) == typeof(MessagePackDeserializeModes.ReferenceMode)) { deserializer.InitReferences(); } return(ValueInterface <T> .ReadValue(deserializer)); }
SerializeObjectAsync <T>(T value, Stream stream, MessagePackFormatterOptions options) { var hGBytes = BytesPool.Rent(); SerializeObject(value, hGBytes, options); var bytes = hGBytes.ToArray(); BytesPool.Return(hGBytes); await stream.WriteAsync(bytes, 0, bytes.Length); }
public static byte[] SerializeObject <T>(T value, MessagePackFormatterOptions options) { var hGBytes = BytesPool.Rent(); SerializeObject(value, hGBytes, options); var ret = hGBytes.ToArray(); BytesPool.Return(hGBytes); return(ret); }
void Serialize <T, TMode>(T value, HGlobalCache <byte> hGCache, MessagePackFormatterOptions options) where TMode : struct { var messagePackSerializer = new MessagePackSerializer <TMode>(this, hGCache, MaxDepth, options); if (typeof(TMode) == typeof(MessagePackSerializeModes.ReferenceMode)) { messagePackSerializer.InitReferences(); } ValueInterface <T> .WriteValue(messagePackSerializer, value); messagePackSerializer.Flush(); }
public int depth; // 当前结构深度。 public MessagePackSerializer( MessagePackFormatterOptions options, int maxDepth, HGlobal hGlobal, MessagePackForamtter foramtter = null, Stream stream = null) { this.options = options; this.maxDepth = maxDepth; this.hGlobal = hGlobal; this.foramtter = foramtter; this.stream = stream; }
public MessagePackSerializer( MessagePackFormatterOptions options, int maxDepth, HGlobalCache <byte> hGCache ) { this.Options = options; this.maxDepth = maxDepth; this.HGCache = hGCache; if (typeof(TMode) == typeof(Reference)) { References = new ReferenceCache <int>(); } }
public static void SerializeObject <T>(T value, Stream stream, MessagePackFormatterOptions options) { var hGBytes = BytesPool.Rent(); if ((options & ReferenceSerializerOptions) != 0) { SerializeObject <T, MessagePackSerializeModes.ReferenceMode>(value, hGBytes, options); } else { SerializeObject <T, MessagePackSerializeModes.StandardMode>(value, hGBytes, options); } hGBytes.WriteTo(stream); BytesPool.Return(hGBytes); }
/// <summary> /// 初始化具有指定配置项的 MessagePack 格式化器。 /// </summary> /// <param name="options">指定配置项</param> public MessagePackFormatter(MessagePackFormatterOptions options = MessagePackFormatterOptions.Default) { Options = options; }
DeserializeObjectAsync(Stream stream, Type type, MessagePackFormatterOptions options) { return(DeserializeObject(await stream.ReadToEndAsync(), type, options)); }
DeserializeObjectAsync <T>(Stream stream, MessagePackFormatterOptions options) { return(DeserializeObject <T>(await stream.ReadToEndAsync(), options)); }
public static T DeserializeObject <T>(Stream stream, MessagePackFormatterOptions options) { return(DeserializeObject <T>(stream.ReadToEnd(), options)); }
public static object DeserializeObject(Stream stream, Type type, MessagePackFormatterOptions options) { return(DeserializeObject(stream.ReadToEnd(), type, options)); }