microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
samples/migration-bot

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

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
4using Microsoft.Bot.Builder;
5using Microsoft.Bot.Builder.Integration.AspNet.Core;
6using Microsoft.Bot.Connector.Authentication;
7using Microsoft.Extensions.DependencyInjection;
8using Microsoft.Extensions.Hosting;
9
10namespace Microsoft.Teams.Plugins.AspNetCore.Extensions;
11
12public 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}