microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
teams.net/Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore.BotBuilder/Extensions
Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore.BotBuilder/Extensions/HostApplicationBuilder.cs
36lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Bot.Builder; |
| 5 | using Microsoft.Bot.Builder.Integration.AspNet.Core; |
| 6 | using Microsoft.Bot.Connector.Authentication; |
| 7 | using Microsoft.Extensions.DependencyInjection; |
| 8 | using Microsoft.Extensions.Hosting; |
| 9 | |
| 10 | namespace Microsoft.Teams.Plugins.AspNetCore.Extensions; |
| 11 | |
| 12 | public static class HostApplicationBuilderExtensions |
| 13 | { |
| 14 | public static IHostApplicationBuilder AddBotBuilder(this IHostApplicationBuilder builder) |
| 15 | { |
| 16 | return builder; |
| 17 | } |
| 18 | |
| 19 | public static IHostApplicationBuilder AddBotBuilder<TBot>(this IHostApplicationBuilder builder, BotFrameworkAuthentication authentication, IBotFrameworkHttpAdapter adapter) where TBot : class, IBot |
| 20 | { |
| 21 | builder.Services.AddSingleton(authentication); |
| 22 | builder.Services.AddSingleton(adapter); |
| 23 | builder.Services.AddTransient<IBot, TBot>(); |
| 24 | |
| 25 | return builder; |
| 26 | } |
| 27 | |
| 28 | public static IHostApplicationBuilder AddBotBuilder<TBot, TBotFrameworkHttpAdapter, TBotFrameworkAuthentication>(this IHostApplicationBuilder builder) where TBot : class, IBot where TBotFrameworkAuthentication : BotFrameworkAuthentication where TBotFrameworkHttpAdapter : class, IBotFrameworkHttpAdapter |
| 29 | { |
| 30 | builder.Services.AddSingleton<BotFrameworkAuthentication, TBotFrameworkAuthentication>(); |
| 31 | builder.Services.AddSingleton<IBotFrameworkHttpAdapter, TBotFrameworkHttpAdapter>(); |
| 32 | builder.Services.AddTransient<IBot, TBot>(); |
| 33 | |
| 34 | return builder; |
| 35 | } |
| 36 | } |