* Added IOptions services checking for host builders

This commit is contained in:
2025-08-04 04:33:34 +04:00
parent cb9e158e6c
commit afb500cfc6
2 changed files with 18 additions and 1 deletions
@@ -75,6 +75,16 @@ namespace Telegrator.Hosting
Services.Configure<ReceiverOptions>(Configuration.GetSection(nameof(ReceiverOptions)));
Services.Configure<TelegramBotClientOptions>(Configuration.GetSection(nameof(TelegramBotClientOptions)), new TelegramBotClientOptionsProxy());
}
else
{
/*
if (null == Services.SingleOrDefault(srvc => srvc.ImplementationType == typeof(IOptions<ReceiverOptions>)))
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'ReceiverOptions' wasn't registered. This configuration is runtime required!");
*/
if (null == Services.SingleOrDefault(srvc => srvc.ImplementationType == typeof(IOptions<TelegramBotClientOptions>)))
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegramBotClientOptions' wasn't registered. This configuration is runtime required!");
}
Services.AddSingleton<IOptions<TelegratorOptions>>(Options.Create(_settings));
Services.AddSingleton<IConfigurationManager>(Configuration);