namespace Core.Configurations.SmartConfigProvider { /// /// Extension methods for adding smart configuration providers to IConfigurationBuilder. /// public static class SmartConfigExtension { /// /// Adds a smart configuration provider using a connection string from appsettings. /// /// The configuration builder to add to /// The key to find the connection string in the ConnectionStrings section. Defaults to "DefaultConnection" /// Optional path to configuration file if different from default appsettings location /// The configuration builder public static IConfigurationBuilder AddSmartConfig(this IConfigurationBuilder builder, string configKey = "DefaultConnection", string path = null) { return builder.AddProvider(new SmartConfigProvider(builder, configKey, path)); } /// /// Adds a smart configuration provider with custom configuration options. /// /// The configuration builder to add to /// Action to configure the smart configuration options /// The configuration builder public static IConfigurationBuilder AddSmartConfig(this IConfigurationBuilder builder, Action setupAction) { var options = new SmartConfigOptions(); setupAction(options); return builder.AddProvider(new SmartConfigProvider(builder, options)); } } }