diff --git a/src/Insight.TelegramBot.DependencyInjection.Polling/PollingOptionsBuilder.cs b/src/Insight.TelegramBot.DependencyInjection.Polling/PollingOptionsBuilder.cs index 8fee910..6f3ed6d 100644 --- a/src/Insight.TelegramBot.DependencyInjection.Polling/PollingOptionsBuilder.cs +++ b/src/Insight.TelegramBot.DependencyInjection.Polling/PollingOptionsBuilder.cs @@ -1,6 +1,7 @@ using System; using Insight.TelegramBot.DependencyInjection.Builders.Base; using Insight.TelegramBot.Polling; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Insight.TelegramBot.DependencyInjection.Polling; @@ -11,6 +12,12 @@ public PollingOptionsBuilder(IServiceCollection services) : base(services) { } + public PollingOptionsBuilder FromConfiguration(IConfiguration configuration) + { + base.FromConfiguration(configuration, $"{nameof(TelegramBotOptions)}:{nameof(PollingOptions)}"); + return this; + } + public override OptionsBuilderBase FromValue(PollingOptions options) { if (options == null) diff --git a/src/Insight.TelegramBot.DependencyInjection.WebHook/WebHookOptionsBuilder.cs b/src/Insight.TelegramBot.DependencyInjection.WebHook/WebHookOptionsBuilder.cs index 13dbca3..635c57e 100644 --- a/src/Insight.TelegramBot.DependencyInjection.WebHook/WebHookOptionsBuilder.cs +++ b/src/Insight.TelegramBot.DependencyInjection.WebHook/WebHookOptionsBuilder.cs @@ -1,5 +1,6 @@ using Insight.TelegramBot.DependencyInjection.Builders.Base; using Insight.TelegramBot.WebHook; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Insight.TelegramBot.DependencyInjection.WebHook; @@ -9,6 +10,12 @@ public sealed class WebHookOptionsBuilder : OptionsBuilderBase public WebHookOptionsBuilder(IServiceCollection services) : base(services) { } + + public WebHookOptionsBuilder FromConfiguration(IConfiguration configuration) + { + base.FromConfiguration(configuration, $"{nameof(TelegramBotOptions)}:{nameof(WebHookOptions)}"); + return this; + } public override OptionsBuilderBase FromValue(WebHookOptions options) { diff --git a/src/Insight.TelegramBot.DependencyInjection/Builders/Base/OptionsBuilderBase.cs b/src/Insight.TelegramBot.DependencyInjection/Builders/Base/OptionsBuilderBase.cs index 6447616..eb88596 100644 --- a/src/Insight.TelegramBot.DependencyInjection/Builders/Base/OptionsBuilderBase.cs +++ b/src/Insight.TelegramBot.DependencyInjection/Builders/Base/OptionsBuilderBase.cs @@ -15,8 +15,8 @@ protected OptionsBuilderBase(IServiceCollection services) Services = services ?? throw new ArgumentNullException(nameof(services)); } - public OptionsBuilderBase FromConfiguration(IConfiguration configuration, - string sectionName = nameof(TOptions)) + protected OptionsBuilderBase FromConfiguration(IConfiguration configuration, + string sectionName) { if (configuration == null) { diff --git a/src/Insight.TelegramBot.DependencyInjection/Builders/TelegramBotOptionsBuilder.cs b/src/Insight.TelegramBot.DependencyInjection/Builders/TelegramBotOptionsBuilder.cs index 923bfdb..6cec314 100644 --- a/src/Insight.TelegramBot.DependencyInjection/Builders/TelegramBotOptionsBuilder.cs +++ b/src/Insight.TelegramBot.DependencyInjection/Builders/TelegramBotOptionsBuilder.cs @@ -1,5 +1,6 @@ using System; using Insight.TelegramBot.DependencyInjection.Builders.Base; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Insight.TelegramBot.DependencyInjection.Builders; @@ -10,6 +11,12 @@ public TelegramBotOptionsBuilder(IServiceCollection services) : base(services) { } + public TelegramBotOptionsBuilder FromConfiguration(IConfiguration configuration) + { + base.FromConfiguration(configuration, nameof(TelegramBotOptions)); + return this; + } + public override OptionsBuilderBase FromValue(TelegramBotOptions options) { if (options == null)