TurnStateFactory Delegate
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.
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;
});