private static IConverter GetConverter(IConverterFactory factory, Type type, object[] converterParameters) { if (factory != null) { if (!factory.CanConvert(type)) { throw new Exception($"Converter factory {factory.GetType()} is not able to convert type '{type}'."); } IConverter converter = factory.Create(type, converterParameters); if (converter == null) { throw new Exception($"{nameof(IConverterFactory.Create)} implementation of {factory.GetType()} did not return a converter for type {type}."); } return(converter); } return(ConverterRegistry.Get(type, converterParameters)); }