Skip to content

Commit

Permalink
Fix options builder
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarovsa committed Jul 10, 2024
1 parent f025539 commit 2beb3a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<PollingOptions> FromValue(PollingOptions options)
{
if (options == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,6 +10,12 @@ public sealed class WebHookOptionsBuilder : OptionsBuilderBase<WebHookOptions>
public WebHookOptionsBuilder(IServiceCollection services) : base(services)
{
}

public WebHookOptionsBuilder FromConfiguration(IConfiguration configuration)
{
base.FromConfiguration(configuration, $"{nameof(TelegramBotOptions)}:{nameof(WebHookOptions)}");
return this;
}

public override OptionsBuilderBase<WebHookOptions> FromValue(WebHookOptions options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ protected OptionsBuilderBase(IServiceCollection services)
Services = services ?? throw new ArgumentNullException(nameof(services));
}

public OptionsBuilderBase<TOptions> FromConfiguration(IConfiguration configuration,
string sectionName = nameof(TOptions))
protected OptionsBuilderBase<TOptions> FromConfiguration(IConfiguration configuration,
string sectionName)
{
if (configuration == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<TelegramBotOptions> FromValue(TelegramBotOptions options)
{
if (options == null)
Expand Down

0 comments on commit 2beb3a2

Please sign in to comment.