InvokeRouteAttribute 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.
Attribute to define a route that handles invoke activities, optionally matching a specific invoke name or name pattern.
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Builder.App.RouteHandler))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class InvokeRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Builder.App.RouteHandler))>]
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type InvokeRouteAttribute = class
inherit Attribute
interface IRouteAttribute
Public Class InvokeRouteAttribute
Inherits Attribute
Implements IRouteAttribute
- Inheritance
-
InvokeRouteAttribute
- Attributes
- Implements
Remarks
Decorate a method with this attribute to register it as a handler for invoke activities. Provide name for an exact match, nameRegex for a pattern match, or neither to match any invoke. name and nameRegex are mutually exclusive. The method must match the RouteHandler delegate signature.
// Match any invoke
[InvokeRoute]
public async Task OnAnyInvokeAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle any invoke activity
}
// Match a specific invoke
[InvokeRoute("myInvoke")]
public async Task OnMyInvokeAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle "myInvoke" invoke
}
// Match an invoke name pattern
[InvokeRoute(nameRegex: "my.*Invoke")]
public async Task OnMyInvokePatternAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle invokes matching pattern
}
Constructors
| Name | Description |
|---|---|
| InvokeRouteAttribute(String, String, Boolean, UInt16, String) |
Attribute to define a route that handles invoke activities, optionally matching a specific invoke name or name pattern. |
Methods
| Name | Description |
|---|---|
| AddRoute(AgentApplication, MethodInfo) | |