protected override IDictionary DeserializeBase(BinaryReader reader, Type objectType, DeserializationContext context) { IDictionary result = (IDictionary)context.CurrentReferenceTypeObject; var count = reader.ReadInt32(); if (count > 0) { for (int i = 0; i < count; i++) { var key = KeyItem.Deserialize(reader, KeyType, context); var value = ValueItem.Deserialize(reader, ValueType, context); result.Add(key, value); } } return(result); }