public KeyValuePair <TKey, TValue> Read(ref ProtoReader.State state, KeyValuePair <TKey, TValue> pair) { TKey key = pair.Key; TValue value = pair.Value; int field; while ((field = state.ReadFieldHeader()) > 0) { switch (field) { case 1: key = state.ReadAny(_keyFeatures, key, _keySerializer); break; case 2: value = state.ReadAny(_valueFeatures, value, _valueSerializer); break; default: state.SkipField(); break; } } if (TypeHelper <TKey> .IsReferenceType && TypeHelper <TKey> .ValueChecker.IsNull(key)) { key = TypeModel.CreateInstance <TKey>(state.Context, _keySerializer); } if (TypeHelper <TValue> .IsReferenceType && TypeHelper <TValue> .ValueChecker.IsNull(value)) { value = TypeModel.CreateInstance <TValue>(state.Context, _valueSerializer); } return(new KeyValuePair <TKey, TValue>(key, value)); }