microsoft/teams.net

Public

mirrored fromhttps://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

core/samples/MigrationBot/MigrationExtensions.cs

38lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Bot.Apps;
5using Microsoft.Teams.Bot.Core;
6using Microsoft.Teams.Bot.Core.Hosting;
7
8namespace MigrationBot;
9
10/// <summary>
11/// Sample-local registration helpers for the Teams SDK side of the migration.
12/// </summary>
13internal static class MigrationExtensions
14{
15 /// <summary>
16 /// Registers <see cref="NewSdkBot"/> as a separate singleton alongside the
17 /// CompatAdapter's own <see cref="TeamsBotApplication"/> instance.
18 ///
19 /// The three underlying bot clients (<see cref="ConversationClient"/>,
20 /// <see cref="UserTokenClient"/>, <see cref="TeamsApiClient"/>) are already
21 /// registered by <c>AddCompatAdapter()</c> and are shared here — both instances
22 /// use the same bot identity and talk to the same Teams endpoints. Only the
23 /// <see cref="TeamsBotApplication"/> itself is separate, giving <see cref="NewSdkBot"/>
24 /// its own isolated router and OnActivity delegate.
25 /// </summary>
26 public static IHostApplicationBuilder AddNewSdkBot(this IHostApplicationBuilder builder)
27 {
28 builder.Services.AddSingleton<NewSdkBot>(sp => new NewSdkBot(
29 sp.GetRequiredService<ConversationClient>(),
30 sp.GetRequiredService<UserTokenClient>(),
31 sp.GetRequiredService<TeamsApiClient>(),
32 sp.GetRequiredService<IHttpContextAccessor>(),
33 sp.GetRequiredService<ILogger<TeamsBotApplication>>()
34 ));
35
36 return builder;
37 }
38}
39