public global::InputData Deserialize(byte[] bytes, int offset, global::MessagePack.IFormatterResolver formatterResolver, out int readSize) { if (global::MessagePack.MessagePackBinary.IsNil(bytes, offset)) { throw new InvalidOperationException("typecode is null, struct not supported"); } var startOffset = offset; var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); offset += readSize; var __Index__ = default(long); var __Right__ = default(bool); var __Left__ = default(bool); var __Up__ = default(bool); var __Down__ = default(bool); for (int i = 0; i < length; i++) { var key = i; switch (key) { case 0: __Index__ = MessagePackBinary.ReadInt64(bytes, offset, out readSize); break; case 1: __Right__ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; case 2: __Left__ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; case 3: __Up__ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; case 4: __Down__ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; default: readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset); break; } offset += readSize; } readSize = offset - startOffset; var ____result = new global::InputData(); ____result.Index = __Index__; ____result.Right = __Right__; ____result.Left = __Left__; ____result.Up = __Up__; ____result.Down = __Down__; return(____result); }
static int ToJsonCore(byte[] bytes, int offset, StringBuilder builder) { var readSize = 0; var type = MessagePackBinary.GetMessagePackType(bytes, offset); switch (type) { case MessagePackType.Integer: var code = bytes[offset]; if (MessagePackCode.MinNegativeFixInt <= code && code <= MessagePackCode.MaxNegativeFixInt) { builder.Append(MessagePackBinary.ReadSByte(bytes, offset, out readSize)); } else if (MessagePackCode.MinFixInt <= code && code <= MessagePackCode.MaxFixInt) { builder.Append(MessagePackBinary.ReadByte(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int8) { builder.Append(MessagePackBinary.ReadSByte(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int16) { builder.Append(MessagePackBinary.ReadInt16(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int32) { builder.Append(MessagePackBinary.ReadInt32(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int64) { builder.Append(MessagePackBinary.ReadInt64(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt8) { builder.Append(MessagePackBinary.ReadByte(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt16) { builder.Append(MessagePackBinary.ReadUInt16(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt32) { builder.Append(MessagePackBinary.ReadUInt32(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt64) { builder.Append(MessagePackBinary.ReadUInt64(bytes, offset, out readSize)); } break; case MessagePackType.Boolean: builder.Append(MessagePackBinary.ReadBoolean(bytes, offset, out readSize) ? "true" : "false"); break; case MessagePackType.Float: var floatCode = bytes[offset]; if (floatCode == MessagePackCode.Float32) { builder.Append(MessagePackBinary.ReadSingle(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else { builder.Append(MessagePackBinary.ReadDouble(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } break; case MessagePackType.String: WriteJsonString(MessagePackBinary.ReadString(bytes, offset, out readSize), builder); break; case MessagePackType.Binary: builder.Append("\"" + Convert.ToBase64String(MessagePackBinary.ReadBytes(bytes, offset, out readSize)) + "\""); break; case MessagePackType.Array: { var length = MessagePackBinary.ReadArrayHeaderRaw(bytes, offset, out readSize); var totalReadSize = readSize; offset += readSize; builder.Append("["); for (int i = 0; i < length; i++) { readSize = ToJsonCore(bytes, offset, builder); offset += readSize; totalReadSize += readSize; if (i != length - 1) { builder.Append(","); } } builder.Append("]"); return(totalReadSize); } case MessagePackType.Map: { var length = MessagePackBinary.ReadMapHeaderRaw(bytes, offset, out readSize); var totalReadSize = readSize; offset += readSize; builder.Append("{"); for (int i = 0; i < length; i++) { // write key { var keyType = MessagePackBinary.GetMessagePackType(bytes, offset); if (keyType == MessagePackType.String || keyType == MessagePackType.Binary) { readSize = ToJsonCore(bytes, offset, builder); } else { builder.Append("\""); readSize = ToJsonCore(bytes, offset, builder); builder.Append("\""); } offset += readSize; totalReadSize += readSize; } builder.Append(":"); // write body { readSize = ToJsonCore(bytes, offset, builder); offset += readSize; totalReadSize += readSize; } if (i != length - 1) { builder.Append(","); } } builder.Append("}"); return(totalReadSize); } case MessagePackType.Extension: var extHeader = MessagePackBinary.ReadExtensionFormatHeader(bytes, offset, out readSize); if (extHeader.TypeCode == ReservedMessagePackExtensionTypeCode.DateTime) { var dt = MessagePackBinary.ReadDateTime(bytes, offset, out readSize); builder.Append("\""); builder.Append(dt.ToString("o", CultureInfo.InvariantCulture)); builder.Append("\""); } #if NETSTANDARD || NETFRAMEWORK else if (extHeader.TypeCode == TypelessFormatter.ExtensionTypeCode) { int startOffset = offset; // prepare type name token offset += 6; var typeNameToken = new StringBuilder(); var typeNameReadSize = ToJsonCore(bytes, offset, typeNameToken); offset += typeNameReadSize; int startBuilderLength = builder.Length; if (extHeader.Length > typeNameReadSize) { // object map or array var typeInside = MessagePackBinary.GetMessagePackType(bytes, offset); if (typeInside != MessagePackType.Array && typeInside != MessagePackType.Map) { builder.Append("{"); } offset += ToJsonCore(bytes, offset, builder); // insert type name token to start of object map or array if (typeInside != MessagePackType.Array) { typeNameToken.Insert(0, "\"$type\":"); } if (typeInside != MessagePackType.Array && typeInside != MessagePackType.Map) { builder.Append("}"); } if (builder.Length - startBuilderLength > 2) { typeNameToken.Append(","); } builder.Insert(startBuilderLength + 1, typeNameToken.ToString()); } else { builder.Append("{\"$type\":\"" + typeNameToken.ToString() + "}"); } readSize = offset - startOffset; } #endif else { var ext = MessagePackBinary.ReadExtensionFormat(bytes, offset, out readSize); builder.Append("["); builder.Append(ext.TypeCode); builder.Append(","); builder.Append("\""); builder.Append(Convert.ToBase64String(ext.Data)); builder.Append("\""); builder.Append("]"); } break; case MessagePackType.Unknown: case MessagePackType.Nil: default: readSize = 1; builder.Append("null"); break; } return(readSize); }
public object Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) { var type = MessagePackBinary.GetMessagePackType(bytes, offset); switch (type) { case MessagePackType.Integer: var code = bytes[offset]; if (MessagePackCode.MinNegativeFixInt <= code && code <= MessagePackCode.MaxNegativeFixInt) { return(MessagePackBinary.ReadSByte(bytes, offset, out readSize)); } else if (MessagePackCode.MinFixInt <= code && code <= MessagePackCode.MaxFixInt) { return(MessagePackBinary.ReadByte(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int8) { return(MessagePackBinary.ReadSByte(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int16) { return(MessagePackBinary.ReadInt16(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int32) { return(MessagePackBinary.ReadInt32(bytes, offset, out readSize)); } else if (code == MessagePackCode.Int64) { return(MessagePackBinary.ReadInt64(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt8) { return(MessagePackBinary.ReadByte(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt16) { return(MessagePackBinary.ReadUInt16(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt32) { return(MessagePackBinary.ReadUInt32(bytes, offset, out readSize)); } else if (code == MessagePackCode.UInt64) { return(MessagePackBinary.ReadUInt64(bytes, offset, out readSize)); } throw new InvalidOperationException("Invalid primitive bytes."); case MessagePackType.Boolean: return(MessagePackBinary.ReadBoolean(bytes, offset, out readSize)); case MessagePackType.Float: if (MessagePackCode.Float32 == bytes[offset]) { return(MessagePackBinary.ReadSingle(bytes, offset, out readSize)); } else { return(MessagePackBinary.ReadDouble(bytes, offset, out readSize)); } case MessagePackType.String: return(MessagePackBinary.ReadString(bytes, offset, out readSize)); case MessagePackType.Binary: return(MessagePackBinary.ReadBytes(bytes, offset, out readSize)); case MessagePackType.Extension: var ext = MessagePackBinary.ReadExtensionFormatHeader(bytes, offset, out readSize); if (ext.TypeCode == ReservedMessagePackExtensionTypeCode.DateTime) { return(MessagePackBinary.ReadDateTime(bytes, offset, out readSize)); } throw new InvalidOperationException("Invalid primitive bytes."); case MessagePackType.Array: { var length = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); var startOffset = offset; offset += readSize; var objectFormatter = formatterResolver.GetFormatter <object>(); var array = new object[length]; for (int i = 0; i < length; i++) { array[i] = objectFormatter.Deserialize(bytes, offset, formatterResolver, out readSize); offset += readSize; } readSize = offset - startOffset; return(array); } case MessagePackType.Map: { var length = MessagePackBinary.ReadMapHeader(bytes, offset, out readSize); var startOffset = offset; offset += readSize; var objectFormatter = formatterResolver.GetFormatter <object>(); var hash = new Dictionary <object, object>(length); for (int i = 0; i < length; i++) { var key = objectFormatter.Deserialize(bytes, offset, formatterResolver, out readSize); offset += readSize; var value = objectFormatter.Deserialize(bytes, offset, formatterResolver, out readSize); offset += readSize; hash.Add(key, value); } readSize = offset - startOffset; return(hash); } case MessagePackType.Nil: readSize = 1; return(null); default: throw new InvalidOperationException("Invalid primitive bytes."); } }
public global::UniP2P.HLAPI.StreamPacket Deserialize(byte[] bytes, int offset, global::MessagePack.IFormatterResolver formatterResolver, out int readSize) { if (global::MessagePack.MessagePackBinary.IsNil(bytes, offset)) { throw new InvalidOperationException("typecode is null, struct not supported"); } var startOffset = offset; var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); offset += readSize; var __NetInstanceID__ = default(string); var __OutComponentType__ = default(string); var __isInstantiate__ = default(bool); var __InstantiateResourcePath__ = default(string); var __value__ = default(byte[]); for (int i = 0; i < length; i++) { var key = i; switch (key) { case 0: __NetInstanceID__ = formatterResolver.GetFormatterWithVerify <string>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 1: __OutComponentType__ = formatterResolver.GetFormatterWithVerify <string>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 2: __isInstantiate__ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; case 3: __InstantiateResourcePath__ = formatterResolver.GetFormatterWithVerify <string>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 4: __value__ = formatterResolver.GetFormatterWithVerify <byte[]>().Deserialize(bytes, offset, formatterResolver, out readSize); break; default: readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset); break; } offset += readSize; } readSize = offset - startOffset; var ____result = new global::UniP2P.HLAPI.StreamPacket(); ____result.NetInstanceID = __NetInstanceID__; ____result.OutComponentType = __OutComponentType__; ____result.isInstantiate = __isInstantiate__; ____result.InstantiateResourcePath = __InstantiateResourcePath__; ____result.value = __value__; return(____result); }
static int ToJsonCore(byte[] bytes, int offset, StringBuilder builder) { var readSize = 0; var type = MessagePackBinary.GetMessagePackType(bytes, offset); switch (type) { case MessagePackType.Integer: var code = bytes[offset]; if (MessagePackCode.MinNegativeFixInt <= code && code <= MessagePackCode.MaxNegativeFixInt) { builder.Append(MessagePackBinary.ReadSByte(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (MessagePackCode.MinFixInt <= code && code <= MessagePackCode.MaxFixInt) { builder.Append(MessagePackBinary.ReadByte(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.Int8) { builder.Append(MessagePackBinary.ReadSByte(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.Int16) { builder.Append(MessagePackBinary.ReadInt16(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.Int32) { builder.Append(MessagePackBinary.ReadInt32(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.Int64) { builder.Append(MessagePackBinary.ReadInt64(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.UInt8) { builder.Append(MessagePackBinary.ReadByte(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.UInt16) { builder.Append(MessagePackBinary.ReadUInt16(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.UInt32) { builder.Append(MessagePackBinary.ReadUInt32(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else if (code == MessagePackCode.UInt64) { builder.Append(MessagePackBinary.ReadUInt64(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } break; case MessagePackType.Boolean: builder.Append(MessagePackBinary.ReadBoolean(bytes, offset, out readSize) ? "true" : "false"); break; case MessagePackType.Float: var floatCode = bytes[offset]; if (floatCode == MessagePackCode.Float32) { builder.Append(MessagePackBinary.ReadSingle(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } else { builder.Append(MessagePackBinary.ReadDouble(bytes, offset, out readSize).ToString(System.Globalization.CultureInfo.InvariantCulture)); } break; case MessagePackType.String: WriteJsonString(MessagePackBinary.ReadString(bytes, offset, out readSize), builder); break; case MessagePackType.Binary: builder.Append("\"" + Convert.ToBase64String(MessagePackBinary.ReadBytes(bytes, offset, out readSize)) + "\""); break; case MessagePackType.Array: { var length = MessagePackBinary.ReadArrayHeaderRaw(bytes, offset, out readSize); var totalReadSize = readSize; offset += readSize; using (MessagePackSecurity.DepthStep()) { builder.Append("["); for (int i = 0; i < length; i++) { readSize = ToJsonCore(bytes, offset, builder); offset += readSize; totalReadSize += readSize; if (i != length - 1) { builder.Append(","); } } builder.Append("]"); } return(totalReadSize); } case MessagePackType.Map: { var length = MessagePackBinary.ReadMapHeaderRaw(bytes, offset, out readSize); var totalReadSize = readSize; offset += readSize; using (MessagePackSecurity.DepthStep()) { builder.Append("{"); for (int i = 0; i < length; i++) { // write key { var keyType = MessagePackBinary.GetMessagePackType(bytes, offset); if (keyType == MessagePackType.String || keyType == MessagePackType.Binary) { readSize = ToJsonCore(bytes, offset, builder); } else { builder.Append("\""); readSize = ToJsonCore(bytes, offset, builder); builder.Append("\""); } offset += readSize; totalReadSize += readSize; } builder.Append(":"); // write body { readSize = ToJsonCore(bytes, offset, builder); offset += readSize; totalReadSize += readSize; } if (i != length - 1) { builder.Append(","); } } builder.Append("}"); } return(totalReadSize); } case MessagePackType.Extension: var extHeader = MessagePackBinary.ReadExtensionFormatHeader(bytes, offset, out readSize); if (extHeader.TypeCode == ReservedMessagePackExtensionTypeCode.DateTime) { var dt = MessagePackBinary.ReadDateTime(bytes, offset, out readSize); builder.Append("\""); builder.Append(dt.ToString("o", CultureInfo.InvariantCulture)); builder.Append("\""); } else { var ext = MessagePackBinary.ReadExtensionFormat(bytes, offset, out readSize); builder.Append("["); builder.Append(ext.TypeCode); builder.Append(","); builder.Append("\""); builder.Append(Convert.ToBase64String(ext.Data)); builder.Append("\""); builder.Append("]"); } break; case MessagePackType.Unknown: case MessagePackType.Nil: default: readSize = 1; builder.Append("null"); break; } return(readSize); }
public void Read() { void Check1 <T, T2>(T data, T2 result, Func <Stream, T2> streamRead) { const int CheckOffset = 10; byte[] bytes = null; var len = MessagePack.Resolvers.StandardResolver.Instance.GetFormatter <T>().Serialize(ref bytes, CheckOffset, data, MessagePack.Resolvers.StandardResolver.Instance); MessagePackBinary.FastResize(ref bytes, CheckOffset + len); var ms = new MemoryStream(bytes); ms.Position = CheckOffset; streamRead(ms).Is(result); } void Check2 <T>(T data, Func <Stream, T> streamRead) { const int CheckOffset = 10; byte[] bytes = null; var len = MessagePack.Resolvers.StandardResolver.Instance.GetFormatter <T>().Serialize(ref bytes, CheckOffset, data, MessagePack.Resolvers.StandardResolver.Instance); MessagePackBinary.FastResize(ref bytes, CheckOffset + len); var ms = new MemoryStream(bytes); ms.Position = CheckOffset; streamRead(ms).Is(data); } Check1(new[] { 1, 10, 100, 1000, 10000, short.MaxValue, int.MaxValue }, 7, x => MessagePackBinary.ReadArrayHeader(x)); Check1(new[] { 1, 10, 100, 1000, 10000, short.MaxValue, int.MaxValue }, (uint)7, x => MessagePackBinary.ReadArrayHeaderRaw(x)); Check1(Nil.Default, true, x => MessagePackBinary.IsNil((x))); Check2(true, x => MessagePackBinary.ReadBoolean(x)); Check2((byte)100, x => MessagePackBinary.ReadByte(x)); Check2(new byte[] { 1, 10, 100, 245 }, x => MessagePackBinary.ReadBytes(x)); Check2('あ', x => MessagePackBinary.ReadChar(x)); Check2(DateTime.UtcNow, x => MessagePackBinary.ReadDateTime(x)); Check2(132, x => MessagePackBinary.ReadInt16(x)); Check2(423, x => MessagePackBinary.ReadInt32(x)); Check2(64332, x => MessagePackBinary.ReadInt64(x)); Check2(Nil.Default, x => MessagePackBinary.ReadNil(x)); Check2(11, x => MessagePackBinary.ReadSByte(x)); Check2(10.31231f, x => MessagePackBinary.ReadSingle(x)); Check2("foobar", x => MessagePackBinary.ReadString(x)); Check2(124, x => MessagePackBinary.ReadUInt16(x)); Check2((uint)432, x => MessagePackBinary.ReadUInt32(x)); Check2((ulong)432, x => MessagePackBinary.ReadUInt64(x)); Check1(new Dictionary <int, int>() { { 1, 2 } }, 1, x => MessagePackBinary.ReadMapHeader(x)); Check1(new Dictionary <int, int>() { { 1, 2 } }, (uint)1, x => MessagePackBinary.ReadMapHeaderRaw(x)); { var block = new object[] { 1, new[] { 1, 10, 100 }, 100 }; var bytes = MessagePackSerializer.Serialize(block); var stream = new MemoryStream(bytes); MessagePackBinary.ReadNext(stream); // array(first) MessagePackBinary.ReadNext(stream); // int MessagePackBinary.ReadNextBlock(stream); // skip array MessagePackBinary.ReadInt32(stream).Is(100); } { var block = new object[] { 1, new Dictionary <int, int> { { 1, 10 }, { 111, 200 } }, 100 }; var bytes = MessagePackSerializer.Serialize(block); var stream = new MemoryStream(bytes); MessagePackBinary.ReadNext(stream); MessagePackBinary.ReadNext(stream); MessagePackBinary.ReadNextBlock(stream); MessagePackBinary.ReadInt32(stream).Is(100); } }
public global::Michelangelo.Models.MichelangeloApi.RuleExtraInfo Deserialize(byte[] bytes, int offset, global::MessagePack.IFormatterResolver formatterResolver, out int readSize) { if (global::MessagePack.MessagePackBinary.IsNil(bytes, offset)) { readSize = 1; return(null); } var startOffset = offset; var length = global::MessagePack.MessagePackBinary.ReadMapHeader(bytes, offset, out readSize); offset += readSize; var __CallsCount__ = default(uint); var __FulfillsAttributes__ = default(string[]); var __FulfillsGoals__ = default(string[]); var __Local__ = default(bool); var __RUID__ = default(string); var __TypeStr__ = default(string); for (int i = 0; i < length; i++) { var stringKey = global::MessagePack.MessagePackBinary.ReadStringSegment(bytes, offset, out readSize); offset += readSize; int key; if (!____keyMapping.TryGetValueSafe(stringKey, out key)) { readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset); goto NEXT_LOOP; } switch (key) { case 0: __CallsCount__ = MessagePackBinary.ReadUInt32(bytes, offset, out readSize); break; case 1: __FulfillsAttributes__ = formatterResolver.GetFormatterWithVerify <string[]>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 2: __FulfillsGoals__ = formatterResolver.GetFormatterWithVerify <string[]>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 3: __Local__ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; case 4: __RUID__ = formatterResolver.GetFormatterWithVerify <string>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 5: __TypeStr__ = formatterResolver.GetFormatterWithVerify <string>().Deserialize(bytes, offset, formatterResolver, out readSize); break; default: readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset); break; } NEXT_LOOP: offset += readSize; } readSize = offset - startOffset; var ____result = new global::Michelangelo.Models.MichelangeloApi.RuleExtraInfo(); ____result.CallsCount = __CallsCount__; ____result.FulfillsAttributes = __FulfillsAttributes__; ____result.FulfillsGoals = __FulfillsGoals__; ____result.Local = __Local__; ____result.RUID = __RUID__; ____result.TypeStr = __TypeStr__; return(____result); }
public override bool ReadBooleanValue() { return(MessagePackBinary.ReadBoolean(this.DecoderStream)); }
public bool Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) { return(MessagePackBinary.ReadBoolean(bytes, offset, out readSize)); }
public global::model.SerializeData Deserialize(byte[] bytes, int offset, global::MessagePack.IFormatterResolver formatterResolver, out int readSize) { if (global::MessagePack.MessagePackBinary.IsNil(bytes, offset)) { readSize = 1; return(null); } var startOffset = offset; var length = global::MessagePack.MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); offset += readSize; var __testNum___ = default(int); var __testFloat___ = default(float); var __testString___ = default(string); var __testBool___ = default(bool); var __testList___ = default(global::System.Collections.Generic.List <string>); var __testDic___ = default(global::System.Collections.Generic.Dictionary <int, string>); for (int i = 0; i < length; i++) { var key = i; switch (key) { case 0: __testNum___ = MessagePackBinary.ReadInt32(bytes, offset, out readSize); break; case 1: __testFloat___ = MessagePackBinary.ReadSingle(bytes, offset, out readSize); break; case 2: __testString___ = formatterResolver.GetFormatterWithVerify <string>().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 3: __testBool___ = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); break; case 4: __testList___ = formatterResolver.GetFormatterWithVerify <global::System.Collections.Generic.List <string> >().Deserialize(bytes, offset, formatterResolver, out readSize); break; case 5: __testDic___ = formatterResolver.GetFormatterWithVerify <global::System.Collections.Generic.Dictionary <int, string> >().Deserialize(bytes, offset, formatterResolver, out readSize); break; default: readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset); break; } offset += readSize; } readSize = offset - startOffset; var ____result = new global::model.SerializeData(); ____result.testNum_ = __testNum___; ____result.testFloat_ = __testFloat___; ____result.testString_ = __testString___; ____result.testBool_ = __testBool___; ____result.testList_ = __testList___; ____result.testDic_ = __testDic___; return(____result); }
public UserCreated <TKey, TUser> Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) { var keyFormatter = formatterResolver.GetFormatter <TKey>(); var claimFormatter = formatterResolver.GetFormatter <Claim>(); var startOffset = offset; var key = keyFormatter.Deserialize(bytes, offset, formatterResolver, out readSize); var usr = (TUser)Activator.CreateInstance(typeof(TUser), key); offset += readSize; usr.UserName = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.NormalizedUserName = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.Email = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.NormalizedEmail = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.EmailConfirmed = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); offset += readSize; usr.PasswordHash = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.SecurityStamp = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.PhoneNumber = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.PhoneNumberConfirmed = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); offset += readSize; usr.TwoFactorEnabled = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); offset += readSize; usr.LockoutEnd = null; if (MessagePackBinary.IsNil(bytes, offset)) { offset++; } else { usr.LockoutEnd = MessagePackBinary.ReadDateTime(bytes, offset, out readSize); offset += readSize; } usr.LockoutEnabled = MessagePackBinary.ReadBoolean(bytes, offset, out readSize); offset += readSize; usr.AccessFailedCount = MessagePackBinary.ReadInt32(bytes, offset, out readSize); offset += readSize; usr.Claims = null; if (MessagePackBinary.IsNil(bytes, offset)) { offset++; } else { var len = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); offset += readSize; usr.Claims = new List <Claim>(len); for (int i = 0; i < len; i++) { var claim = claimFormatter.Deserialize(bytes, offset, formatterResolver, out readSize); offset += readSize; usr.Claims.Add(claim); } } usr.Logins = null; if (MessagePackBinary.IsNil(bytes, offset)) { offset++; } else { var len = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); offset += readSize; usr.Logins = new List <ImmutableUserLoginInfo>(len); for (int i = 0; i < len; i++) { var loginProvider = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; var providerKey = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; var displayName = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.Logins.Add(new ImmutableUserLoginInfo(loginProvider, providerKey, displayName)); } } usr.Tokens = null; if (MessagePackBinary.IsNil(bytes, offset)) { offset++; } else { var len = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize); offset += readSize; usr.Tokens = new List <ImmutableIdentityUserToken>(len); for (int i = 0; i < len; i++) { var loginProvider = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; var name = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; var value = MessagePackBinary.ReadString(bytes, offset, out readSize); offset += readSize; usr.Tokens.Add(new ImmutableIdentityUserToken(loginProvider, name, value)); } } readSize = offset - startOffset; return(new UserCreated <TKey, TUser>(usr)); }