Share via


TurnStateFactory Delegate

Definition

TurnState for an Agent is created at the beginning of a Turn by invoking the specified factory delegate.

public delegate Microsoft.Agents.Builder.State.ITurnState TurnStateFactory();
type TurnStateFactory = delegate of unit -> ITurnState
Public Delegate Function TurnStateFactory() As ITurnState 

Return Value

Remarks

The default implementation of this is

() => new TurnState(service.GetService<IStorage>()

If IStorage was not DI'd, an (effectively) singleton instance should be used:

var storage = new MemoryStorage();  // MemoryStorage for local dev
services.AddTransient<IAgent>(sp =>
{
    var options = new AgentApplicationOptions(storage);
    var app = new AgentApplication(options);

    ...

    return app;
});

Applies to

See also