From b8e4398b50f22653924373f03d916a21d813852b Mon Sep 17 00:00:00 2001 From: Rikitav Date: Sat, 2 Aug 2025 00:27:23 +0400 Subject: [PATCH] * Moved configuration to post build actions * Added option to completelly disable automatic configuration --- Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj | 2 +- Telegrator.Hosting/TelegramBotHostBuilder.cs | 11 +++++++---- Telegrator.Hosting/TelegramBotHostBuilderSettings.cs | 6 ++++++ Telegrator.Hosting/Telegrator.Hosting.csproj | 2 +- Telegrator/Telegrator.csproj | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj b/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj index 8af57e2..759ce3e 100644 --- a/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj +++ b/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj @@ -15,7 +15,7 @@ True LICENSE README.md - 1.0.8 + 1.0.8.1 diff --git a/Telegrator.Hosting/TelegramBotHostBuilder.cs b/Telegrator.Hosting/TelegramBotHostBuilder.cs index fc1ef65..a5b3d39 100644 --- a/Telegrator.Hosting/TelegramBotHostBuilder.cs +++ b/Telegrator.Hosting/TelegramBotHostBuilder.cs @@ -49,10 +49,6 @@ namespace Telegrator.Hosting _handlers = new HostHandlersCollection(Services, _settings); _innerBuilder.Logging.ClearProviders(); - - Services.Configure(Configuration.GetSection(nameof(TelegratorOptions))); - Services.Configure(Configuration.GetSection(nameof(ReceiverOptions))); - Services.Configure(Configuration.GetSection(nameof(TelegramBotClientOptions)), new TelegramBotClientOptionsProxy()); } /// @@ -73,6 +69,13 @@ namespace Telegrator.Hosting } } + if (!_settings.DisableAutoConfigure) + { + Services.Configure(Configuration.GetSection(nameof(TelegratorOptions))); + Services.Configure(Configuration.GetSection(nameof(ReceiverOptions))); + Services.Configure(Configuration.GetSection(nameof(TelegramBotClientOptions)), new TelegramBotClientOptionsProxy()); + } + return new TelegramBotHost(_innerBuilder, _handlers); } } diff --git a/Telegrator.Hosting/TelegramBotHostBuilderSettings.cs b/Telegrator.Hosting/TelegramBotHostBuilderSettings.cs index 6f3b891..c89bbc7 100644 --- a/Telegrator.Hosting/TelegramBotHostBuilderSettings.cs +++ b/Telegrator.Hosting/TelegramBotHostBuilderSettings.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; namespace Telegrator.Hosting { @@ -8,6 +9,11 @@ namespace Telegrator.Hosting /// public class TelegramBotHostBuilderSettings() : TelegratorOptions { + /// + /// Disables automatic configuration for all of required instances + /// + public bool DisableAutoConfigure { get; set; } + /// public bool DisableDefaults { get; set; } diff --git a/Telegrator.Hosting/Telegrator.Hosting.csproj b/Telegrator.Hosting/Telegrator.Hosting.csproj index d46d425..a8fa0bb 100644 --- a/Telegrator.Hosting/Telegrator.Hosting.csproj +++ b/Telegrator.Hosting/Telegrator.Hosting.csproj @@ -16,7 +16,7 @@ True LICENSE README.md - 1.0.8 + 1.0.8.1 diff --git a/Telegrator/Telegrator.csproj b/Telegrator/Telegrator.csproj index f3490e8..79d8814 100644 --- a/Telegrator/Telegrator.csproj +++ b/Telegrator/Telegrator.csproj @@ -17,7 +17,7 @@ True True LICENSE - 1.0.8 + 1.0.8.1