ServiceCollectionExtensions.AddAgent Method
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.
Overloads
| AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>) |
Adds an Agent via lambda construction.
|
| AddAgent<TAdapter>(IHostApplicationBuilder, Func<IServiceProvider,IAgent>) |
This is the same as AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>), except allows the
use of any |
| AddAgent<TAgent,TAdapter>(IHostApplicationBuilder) |
Same as AddAgent<TAgent>(IHostApplicationBuilder) but allows for use of
any |
| AddAgent<TAgent>(IHostApplicationBuilder) |
Adds an Agent which subclasses
|
AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>)
Adds an Agent via lambda construction.
builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgentApplicationOptions();
builder.AddAgent(sp =>
{
var options = new AgentApplicationOptions()
{
TurnStateFactory = () => new TurnState(sp.GetService<IStorage>());
};
var app = new AgentApplication(options);
...
return app;
});
public static Microsoft.Extensions.Hosting.IHostApplicationBuilder AddAgent(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, Func<IServiceProvider,Microsoft.Agents.Builder.IAgent> implementationFactory);
static member AddAgent : Microsoft.Extensions.Hosting.IHostApplicationBuilder * Func<IServiceProvider, Microsoft.Agents.Builder.IAgent> -> Microsoft.Extensions.Hosting.IHostApplicationBuilder
<Extension()>
Public Function AddAgent (builder As IHostApplicationBuilder, implementationFactory As Func(Of IServiceProvider, IAgent)) As IHostApplicationBuilder
Parameters
- builder
- IHostApplicationBuilder
- implementationFactory
- Func<IServiceProvider,IAgent>
Returns
Remarks
This will also calls AddAgentCore(IHostApplicationBuilder) and uses CloudAdapter. The Agent is registered as Transient.
Applies to
AddAgent<TAdapter>(IHostApplicationBuilder, Func<IServiceProvider,IAgent>)
This is the same as AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>), except allows the
use of any CloudAdapter subclass.
public static Microsoft.Extensions.Hosting.IHostApplicationBuilder AddAgent<TAdapter>(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, Func<IServiceProvider,Microsoft.Agents.Builder.IAgent> implementationFactory) where TAdapter : Microsoft.Agents.Hosting.AspNetCore.CloudAdapter;
static member AddAgent : Microsoft.Extensions.Hosting.IHostApplicationBuilder * Func<IServiceProvider, Microsoft.Agents.Builder.IAgent> -> Microsoft.Extensions.Hosting.IHostApplicationBuilder (requires 'Adapter :> Microsoft.Agents.Hosting.AspNetCore.CloudAdapter)
<Extension()>
Public Function AddAgent(Of TAdapter As CloudAdapter) (builder As IHostApplicationBuilder, implementationFactory As Func(Of IServiceProvider, IAgent)) As IHostApplicationBuilder
Type Parameters
- TAdapter
Parameters
- builder
- IHostApplicationBuilder
- implementationFactory
- Func<IServiceProvider,IAgent>
Returns
Applies to
AddAgent<TAgent,TAdapter>(IHostApplicationBuilder)
Same as AddAgent<TAgent>(IHostApplicationBuilder) but allows for use of
any CloudAdapter subclass.
public static Microsoft.Extensions.Hosting.IHostApplicationBuilder AddAgent<TAgent,TAdapter>(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder) where TAgent : class, Microsoft.Agents.Builder.IAgent where TAdapter : Microsoft.Agents.Hosting.AspNetCore.CloudAdapter;
static member AddAgent : Microsoft.Extensions.Hosting.IHostApplicationBuilder -> Microsoft.Extensions.Hosting.IHostApplicationBuilder (requires 'Agent : null and 'Agent :> Microsoft.Agents.Builder.IAgent and 'Adapter :> Microsoft.Agents.Hosting.AspNetCore.CloudAdapter)
<Extension()>
Public Function AddAgent(Of TAgent As {Class, IAgent}, TAdapter As {Class, IAgent}) (builder As IHostApplicationBuilder) As IHostApplicationBuilder
Type Parameters
- TAgent
- TAdapter
Parameters
- builder
- IHostApplicationBuilder
Returns
Applies to
AddAgent<TAgent>(IHostApplicationBuilder)
Adds an Agent which subclasses AgentApplication
builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgentApplicationOptions();
builder.AddAgent<MyAgent>();
public static Microsoft.Extensions.Hosting.IHostApplicationBuilder AddAgent<TAgent>(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder) where TAgent : class, Microsoft.Agents.Builder.IAgent;
static member AddAgent : Microsoft.Extensions.Hosting.IHostApplicationBuilder -> Microsoft.Extensions.Hosting.IHostApplicationBuilder (requires 'Agent : null and 'Agent :> Microsoft.Agents.Builder.IAgent)
<Extension()>
Public Function AddAgent(Of TAgent As {Class, IAgent}) (builder As IHostApplicationBuilder) As IHostApplicationBuilder
Type Parameters
- TAgent
Parameters
- builder
- IHostApplicationBuilder
Returns
Remarks
This will also call AddAgentCore(IHostApplicationBuilder) and uses CloudAdapter. The Agent is registered as Transient.