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 void ConvertTest() { const string str = "JXU3MkQ3JXU0RjFGJXU2NjJGJXU0RTE2JXU3NTRDJXU0RTBBJXU2NzAwJXU1RTA1JXU3Njg0JXU0RUJB"; AreEqual(XConvert <string> .Convert(XConvert <byte[]> .Convert(str)), str); AreEqual(XConvert <int> .Convert(XConvert <BigInteger> .Convert(int.MinValue)), int.MinValue); AreEqual(XConvert <BigInteger> .Convert(XConvert <byte[]> .Convert((BigInteger)ulong.MaxValue)), (BigInteger)ulong.MaxValue); AreEqual(XConvert <string> .FromObject(XConvert.ToObject(str, typeof(byte[]))), str); AreEqual(XConvert <int> .FromObject(XConvert.Cast(int.MinValue, typeof(BigInteger))), int.MinValue); AreEqual(XConvert <BigInteger> .FromObject(XConvert <byte[]> .FromObject((BigInteger)ulong.MaxValue)), (BigInteger)ulong.MaxValue); }