* Moved configuration to post build actions

* Added option to completelly disable automatic configuration
This commit is contained in:
2025-08-02 00:27:23 +04:00
parent 088d6166ce
commit b8e4398b50
5 changed files with 16 additions and 7 deletions
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.8</Version>
<Version>1.0.8.1</Version>
</PropertyGroup>
<ItemGroup>
+7 -4
View File
@@ -49,10 +49,6 @@ namespace Telegrator.Hosting
_handlers = new HostHandlersCollection(Services, _settings);
_innerBuilder.Logging.ClearProviders();
Services.Configure<TelegratorOptions>(Configuration.GetSection(nameof(TelegratorOptions)));
Services.Configure<ReceiverOptions>(Configuration.GetSection(nameof(ReceiverOptions)));
Services.Configure<TelegramBotClientOptions>(Configuration.GetSection(nameof(TelegramBotClientOptions)), new TelegramBotClientOptionsProxy());
}
/// <summary>
@@ -73,6 +69,13 @@ namespace Telegrator.Hosting
}
}
if (!_settings.DisableAutoConfigure)
{
Services.Configure<TelegratorOptions>(Configuration.GetSection(nameof(TelegratorOptions)));
Services.Configure<ReceiverOptions>(Configuration.GetSection(nameof(ReceiverOptions)));
Services.Configure<TelegramBotClientOptions>(Configuration.GetSection(nameof(TelegramBotClientOptions)), new TelegramBotClientOptionsProxy());
}
return new TelegramBotHost(_innerBuilder, _handlers);
}
}
@@ -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
/// </summary>
public class TelegramBotHostBuilderSettings() : TelegratorOptions
{
/// <summary>
/// Disables automatic configuration for all of required <see cref="IOptions{TOptions}"/> instances
/// </summary>
public bool DisableAutoConfigure { get; set; }
/// <inheritdoc cref="HostApplicationBuilderSettings.DisableDefaults"/>
public bool DisableDefaults { get; set; }
+1 -1
View File
@@ -16,7 +16,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.8</Version>
<Version>1.0.8.1</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -17,7 +17,7 @@
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>1.0.8</Version>
<Version>1.0.8.1</Version>
</PropertyGroup>
<ItemGroup>