public T Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize) { if (MessagePackBinary.IsNil(bytes, offset)) { readSize = 1; return(null); } var formatter = formatterResolver.GetFormatterWithVerify <object>(); var startOffset = offset; var count = MessagePackBinary.ReadMapHeader(bytes, offset, out readSize); offset += readSize; var dict = CollectionHelpers <T, IEqualityComparer> .CreateHashCollection(count, MessagePackSecurity.Active.GetEqualityComparer()); using (MessagePackSecurity.DepthStep()) { for (int i = 0; i < count; i++) { var key = formatter.Deserialize(bytes, offset, formatterResolver, out readSize); offset += readSize; var value = formatter.Deserialize(bytes, offset, formatterResolver, out readSize); offset += readSize; dict.Add(key, value); } } readSize = offset - startOffset; return(dict); }
protected override TDictionary Create(int count) { return(CollectionHelpers <TDictionary, IEqualityComparer <TKey> > .CreateHashCollection(count, MessagePackSecurity.Active.GetEqualityComparer <TKey>())); }