private ValueSerializer GetCustomDeserializer([NotNull] Type type) { //do we already have a deserializer for this type? if (_deserializers.TryGetValue(type, out var serializer)) { return(serializer); } //is there a deserializer factory that can handle this type? foreach (var valueSerializerFactory in Options.ValueSerializerFactories) { if (valueSerializerFactory.CanDeserialize(this, type)) { return(valueSerializerFactory.BuildSerializer(this, type, _deserializers)); } } //none of the above, lets create a POCO object deserializer serializer = new ObjectSerializer(type); //add it to the serializer lookup in case of recursive serialization if (!_deserializers.TryAdd(type, serializer)) { return(_deserializers[type]); } //build the serializer IL code CodeGenerator.BuildSerializer(this, (ObjectSerializer)serializer); return(serializer); }