* Moved configuration to post build actions
* Added option to completelly disable automatic configuration
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user