Fixed extensions conflict

This commit is contained in:
2026-03-07 19:38:10 +04:00
parent 80a76c3d0a
commit 16b6215a31
+3 -10
View File
@@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Telegram.Bot; using Telegram.Bot;
using Telegrator.Core; using Telegrator.Core;
using Telegrator.Hosting;
using Telegrator.Hosting.Web; using Telegrator.Hosting.Web;
using Telegrator.Mediation; using Telegrator.Mediation;
using Telegrator.Providers; using Telegrator.Providers;
@@ -25,7 +24,7 @@ namespace Telegrator
/// </summary> /// </summary>
public const string HandlersCollectionPropertyKey = nameof(IHandlersCollection); public const string HandlersCollectionPropertyKey = nameof(IHandlersCollection);
extension(IHostApplicationBuilder builder) extension(WebApplicationBuilder builder)
{ {
/// <summary> /// <summary>
/// Gets the <see cref="IHandlersCollection"/> from the builder properties. /// Gets the <see cref="IHandlersCollection"/> from the builder properties.
@@ -34,13 +33,7 @@ namespace Telegrator
{ {
get get
{ {
if (builder is TelegramBotHostBuilder botHostBuilder) return (IHandlersCollection)builder.Host.Properties[HandlersCollectionPropertyKey];
return botHostBuilder.Handlers;
if (builder is TelegramBotWebHostBuilder webBotHostBuilder)
return webBotHostBuilder.Handlers;
return (IHandlersCollection)builder.Properties[HandlersCollectionPropertyKey];
} }
} }
} }
@@ -67,7 +60,7 @@ namespace Telegrator
options.GlobalCancellationToken = globallCancell.Token; options.GlobalCancellationToken = globallCancell.Token;
services.AddSingleton(Options.Create(options)); services.AddSingleton(Options.Create(options));
services.AddKeyedSingleton("cancell", globallCancell); services.AddKeyedSingleton("cancell", globallCancell);
1
if (handlers != null) if (handlers != null)
{ {
if (handlers is IHandlersManager manager) if (handlers is IHandlersManager manager)