TeamsExtensionAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Marks an AgentApplication subclass to automatically receive a
generated Teams property of type TeamsAgentExtension.
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class TeamsExtensionAttribute : Microsoft.Agents.Builder.App.AgentExtensionAttribute<Microsoft.Agents.Extensions.MSTeams.TeamsAgentExtension>
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)>]
type TeamsExtensionAttribute = class
inherit AgentExtensionAttribute<TeamsAgentExtension>
Public NotInheritable Class TeamsExtensionAttribute
Inherits AgentExtensionAttribute(Of TeamsAgentExtension)
- Inheritance
- Attributes
Remarks
The decorated class must be declared as partial. When the class is compiled, a source generator creates a companion partial class that exposes a TeamsAgentExtension through a Teams property. The extension is lazily initialized and registered with the application on first access.
[TeamsExtension]
public partial class MyAgent(AgentApplicationOptions options) : AgentApplication(options)
{
[TeamsChannelCreatedRoute]
public async Task OnChannelCreatedAsync(ITeamsTurnContext turnContext, ITurnState turnState,
ChannelInfo channelInfo, CancellationToken cancellationToken)
{
// Teams property is available here
_ = Teams;
}
}
Constructors
| Name | Description |
|---|---|
| TeamsExtensionAttribute() | |