AgentPrismServiceCollectionExtensions
AgentPrism.Core.dllExtensions that register AgentPrism with dependency injection.
public static class AgentPrismServiceCollectionExtensionsInheritance
Section titled “Inheritance”object ← AgentPrismServiceCollectionExtensions
Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Methods
Section titled “Methods”AddAgentPrism(IHostApplicationBuilder)
Section titled “ AddAgentPrism(IHostApplicationBuilder)”Adds AgentPrism to the host application builder and reads settings from
the AgentPrism section.
public static IAgentPrismBuilder AddAgentPrism(this IHostApplicationBuilder builder)Parameters
Section titled “Parameters”builder IHostApplicationBuilder
The host application builder.
Returns
Section titled “Returns”The configuration chain.
Remarks
Section titled “Remarks”The one call every AgentPrism application starts with. On its own it runs with in-memory stores and needs no database; a provider and a store are added to the chain it returns.
var builder = WebApplication.CreateBuilder(args);
builder.AddAgentPrism() .UseOpenAI(builder.Configuration["OpenAI:ApiKey"]!) .UsePostgreSql(builder.Configuration.GetConnectionString("AgentPrism")!);Exceptions
Section titled “Exceptions”builder is null.
AddAgentPrism(IServiceCollection, IConfiguration?)
Section titled “ AddAgentPrism(IServiceCollection, IConfiguration?)”Adds AgentPrism to the service collection.
public static IAgentPrismBuilder AddAgentPrism(this IServiceCollection services, IConfiguration? configurationSection = null)Parameters
Section titled “Parameters”services IServiceCollection
Service collection.
configurationSection IConfiguration?
Configuration section settings are read from.
Returns
Section titled “Returns”The configuration chain.
Remarks
Section titled “Remarks”All services are registered with TryAdd. If you register your own
implementation before this call, yours wins; AgentPrism does not overwrite it.
When no additional configuration is done, AgentPrism runs with in-memory stores and requires no database.
Exceptions
Section titled “Exceptions”services is null.
AddJobHandler<THandler>(IServiceCollection)
Section titled “ AddJobHandler<THandler>(IServiceCollection)”Adds an IJobHandler extension point.
public static IServiceCollection AddJobHandler<THandler>(this IServiceCollection services) where THandler : class, IJobHandlerParameters
Section titled “Parameters”services IServiceCollection
Service collection.
Returns
Section titled “Returns”The same collection, for chaining.
Type Parameters
Section titled “Type Parameters”THandler
The handler type to add.
Remarks
Section titled “Remarks”Evaluation registers its own handler with this method.
TryAddEnumerable is used: if the same type is added twice, only
the first counts.
builder.Services.AddJobHandler<NightlyReportJobHandler>();Exceptions
Section titled “Exceptions”services is null.
UseScheduling(IServiceCollection, Action<AgentPrismSchedulingOptions>?)
Section titled “ UseScheduling(IServiceCollection, Action<AgentPrismSchedulingOptions>?)”Sets batch and scheduled run settings from code.
public static IServiceCollection UseScheduling(this IServiceCollection services, Action<AgentPrismSchedulingOptions>? configure = null)Parameters
Section titled “Parameters”services IServiceCollection
Service collection.
configure Action<AgentPrismSchedulingOptions>?
Settings modifier. When not given, only the defaults/configuration apply.
Returns
Section titled “Returns”The same collection, for chaining.
Remarks
Section titled “Remarks”The job queue and scheduling stores are already registered by
AddAgentPrism; this method only changes the settings (e.g.
turning off this process’s background worker with
o.RunWorker = false). PostConfigure is used, so the value
given from code always wins over the value coming from the configuration file.
// A web instance that serves requests and leaves the jobs to a worker process.builder.Services.UseScheduling(o => o.RunWorker = false);Exceptions
Section titled “Exceptions”services is null.