EventRouteAttribute Class

Definition

Attribute to define a route that handles event activities, optionally matching a specific event name or name pattern.

[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class EventRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type EventRouteAttribute = class
    inherit Attribute
    interface IRouteAttribute
Public Class EventRouteAttribute
Inherits Attribute
Implements IRouteAttribute
Inheritance
EventRouteAttribute
Attributes
Implements

Remarks

Decorate a method with this attribute to register it as a handler for event activities. Provide name for an exact match, nameRegex for a pattern match, or neither to match any event. name and nameRegex are mutually exclusive. The method must match the RouteHandler delegate signature.

// Match any event
[EventRoute]
public async Task OnAnyEventAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle any event activity
}

// Match a specific event
[EventRoute("myEvent")]
public async Task OnMyEventAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle "myEvent" event
}

// Match an event name pattern
[EventRoute(nameRegex: "my.*Event")]
public async Task OnMyEventPatternAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle events matching pattern
}

Constructors

Name Description
EventRouteAttribute(String, String, Boolean, UInt16, String)

Attribute to define a route that handles event activities, optionally matching a specific event name or name pattern.

Methods

Name Description
AddRoute(AgentApplication, MethodInfo)

Applies to