ภาษา

AgentHostExtensions.AddAgent Method

Definition

Overloads

Name Description
AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>)

Adds an Agent via lambda construction.

builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgent(sp =>
{
   var options = new AgentApplicationOptions()
   {
      TurnStateFactory = () => new TurnState(sp.GetService<IStorage>());
   };

   var app = new AgentApplication(options);

   ...

   return app;
});
AddAgent<TAdapter>(IHostApplicationBuilder, Func<IServiceProvider,IAgent>)

This is the same as AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>), except allows the use of any CloudAdapter subclass.

AddAgent<TAgent,TAdapter>(IHostApplicationBuilder)

Same as AddAgent<TAgent>(IHostApplicationBuilder) but allows for use of any CloudAdapter subclass.

builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgent<MyAgent, MyCustomAdapter>();
AddAgent<TAgent>(IHostApplicationBuilder)

Adds an Agent which subclasses AgentApplication

builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgent<MyAgent>();

AddAgent(IHostApplicationBuilder, Func<IServiceProvider,IAgent>)

Adds an Agent via lambda construction.

builder.Services.AddSingleton<IStorage, MemoryStorage>();
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

implementationFactory
Func<IServiceProvider,IAgent>

Returns

The same instance of IHostApplicationBuilder to allow for method chaining.

Remarks

This will also call AddAgentCore(IHostApplicationBuilder) and uses CloudAdapter. The Agent is registered as Transient. AgentApplicationOptions is automatically registered if not already present.

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

implementationFactory
Func<IServiceProvider,IAgent>

Returns

The same instance of IHostApplicationBuilder to allow for method chaining.

Remarks

AgentApplicationOptions is automatically registered if not already present.

Applies to

AddAgent<TAgent,TAdapter>(IHostApplicationBuilder)

Same as AddAgent<TAgent>(IHostApplicationBuilder) but allows for use of any CloudAdapter subclass.

builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgent<MyAgent, MyCustomAdapter>();
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

Returns

The same instance of IHostApplicationBuilder to allow for method chaining.

Remarks

AgentApplicationOptions is automatically registered if not already present.

Applies to

AddAgent<TAgent>(IHostApplicationBuilder)

Adds an Agent which subclasses AgentApplication

builder.Services.AddSingleton<IStorage, MemoryStorage>();
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

Returns

The same instance of IHostApplicationBuilder to allow for method chaining.

Remarks

This will also call AddAgentCore(IHostApplicationBuilder) and uses CloudAdapter. The Agent is registered as Transient. AgentApplicationOptions is automatically registered if not already present.

Applies to