public SettingsRegistrationService(IConfigInjectorLogger logger,
                                           ITypeProvider typeProvider,
                                           ISettingKeyConvention[] settingKeyConventions,
                                           ISettingsReader settingsReader,
                                           ISettingsOverrider settingsOverrider,
                                           SettingValueConverter settingValueConverter,
                                           bool allowEntriesInWebConfigThatDoNotHaveSettingsClasses,
                                           Action<IConfigurationSetting> registerAsSingleton)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            if (typeProvider == null) throw new ArgumentNullException("typeProvider");
            if (settingKeyConventions == null) throw new ArgumentNullException("settingKeyConventions");
            if (settingsReader == null) throw new ArgumentNullException("settingsReader");
            if (settingsOverrider == null) throw new ArgumentNullException("settingsOverrider");
            if (settingValueConverter == null) throw new ArgumentNullException("settingValueConverter");
            if (registerAsSingleton == null) throw new ArgumentNullException("registerAsSingleton");

            _logger = logger;
            _typeProvider = typeProvider;
            _settingKeyConventions = settingKeyConventions;
            _settingsReader = settingsReader;
            _settingsOverrider = settingsOverrider;
            _settingValueConverter = settingValueConverter;
            _allowEntriesInWebConfigThatDoNotHaveSettingsClasses = allowEntriesInWebConfigThatDoNotHaveSettingsClasses;
            _registerAsSingleton = registerAsSingleton;
        }
        public SettingsRegistrationService(IConfigInjectorLogger logger,
                                           ITypeProvider typeProvider,
                                           ISettingKeyConvention[] settingKeyConventions,
                                           ISettingsReader settingsReader,
                                           ISettingsOverrider settingsOverrider,
                                           SettingValueConverter settingValueConverter,
                                           bool allowEntriesInWebConfigThatDoNotHaveSettingsClasses,
                                           Action <IConfigurationSetting> registerAsSingleton)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (typeProvider == null)
            {
                throw new ArgumentNullException("typeProvider");
            }
            if (settingKeyConventions == null)
            {
                throw new ArgumentNullException("settingKeyConventions");
            }
            if (settingsReader == null)
            {
                throw new ArgumentNullException("settingsReader");
            }
            if (settingsOverrider == null)
            {
                throw new ArgumentNullException("settingsOverrider");
            }
            if (settingValueConverter == null)
            {
                throw new ArgumentNullException("settingValueConverter");
            }
            if (registerAsSingleton == null)
            {
                throw new ArgumentNullException("registerAsSingleton");
            }

            _logger                = logger;
            _typeProvider          = typeProvider;
            _settingKeyConventions = settingKeyConventions;
            _settingsReader        = settingsReader;
            _settingsOverrider     = settingsOverrider;
            _settingValueConverter = settingValueConverter;
            _allowEntriesInWebConfigThatDoNotHaveSettingsClasses = allowEntriesInWebConfigThatDoNotHaveSettingsClasses;
            _registerAsSingleton = registerAsSingleton;
        }
        public void DoYourThing()
        {
            if (_typeProvider == null) throw new ConfigurationException("You must specify a type provider used to scan for configuration settings.");
            if (_registerAsSingleton == null) throw new ConfigurationException("You must provide a registration action.");

            var settingsReader = _settingsReader ?? new AppSettingsReader(_exclusionRules.ToArray());
            var settingsOverrider = _settingsOverrider ?? new NoOpSettingsOverrider();
            var settingValueConverter = new SettingValueConverter(_customValueParsers.ToArray());

            var settingsRegistrationService = new SettingsRegistrationService(_logger,
                                                                              _typeProvider,
                                                                              _settingKeyConventions.ToArray(),
                                                                              settingsReader,
                                                                              settingsOverrider,
                                                                              settingValueConverter,
                                                                              _allowConfigurationEntriesThatDoNotHaveSettingsClasses,
                                                                              _registerAsSingleton);
            settingsRegistrationService.RegisterConfigurationSettings();
        }
        public void WeShouldThrowAnException(Type settingValueType, string settingValue)
        {
            var converter = new SettingValueConverter();

            Should.Throw<SettingParsingException>(() => converter.ParseSettingValue(settingValueType, settingValue));
        }