Class ArcApplicationBuilder

Namespace
Cratis.Arc
Assembly
Cratis.Arc.Core.dll

A builder for Arc applications.

public class ArcApplicationBuilder : IHostApplicationBuilder
Inheritance
ArcApplicationBuilder
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the ArcApplicationBuilder class.

The builder starts out with a DefaultServiceProviderFactory that has ValidateOnBuild off and ValidateScopes taken from the environment, exactly as the host would derive it. Arc supplies registrations contextually — IHostApplicationBuilder, the type a convention binding is for, values only an executing command can hand over — and eager validation constructs every registration up front and can resolve none of them, so Build() would fail outright in Development, where the host turns eager validation on.

This is applied while the builder is being constructed, so it is a default rather than an override: any ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>, Action<TContainerBuilder>?) call an application makes — before or after AddCratisArc — replaces it and wins.

Constructors

ArcApplicationBuilder(string[]?)

A builder for Arc applications.

public ArcApplicationBuilder(string[]? args = null)

Parameters

args string[]

Command line arguments.

Remarks

Initializes a new instance of the ArcApplicationBuilder class.

The builder starts out with a DefaultServiceProviderFactory that has ValidateOnBuild off and ValidateScopes taken from the environment, exactly as the host would derive it. Arc supplies registrations contextually — IHostApplicationBuilder, the type a convention binding is for, values only an executing command can hand over — and eager validation constructs every registration up front and can resolve none of them, so Build() would fail outright in Development, where the host turns eager validation on.

This is applied while the builder is being constructed, so it is a default rather than an override: any ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>, Action<TContainerBuilder>?) call an application makes — before or after AddCratisArc — replaces it and wins.

Properties

Configuration

Gets the set of key/value configuration properties.

public IConfigurationManager Configuration { get; }

Property Value

IConfigurationManager

Remarks

This can be mutated by adding more configuration sources, which will update its current view.

Environment

Gets the information about the hosting environment an application is running in.

public IHostEnvironment Environment { get; }

Property Value

IHostEnvironment

Logging

Gets a collection of logging providers for the application to compose. This is useful for adding new logging providers.

public ILoggingBuilder Logging { get; }

Property Value

ILoggingBuilder

Metrics

Gets a builder that allows enabling metrics and directing their output.

public IMetricsBuilder Metrics { get; }

Property Value

IMetricsBuilder

Properties

Gets a central location for sharing state between components during the host building process.

public IDictionary<object, object> Properties { get; }

Property Value

IDictionary<object, object>

Services

Gets a collection of services for the application to compose. This is useful for adding user provided or framework provided services.

public IServiceCollection Services { get; }

Property Value

IServiceCollection

Methods

Build()

Builds the ArcApplication.

public ArcApplication Build()

Returns

ArcApplication

A configured ArcApplication.

ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>, Action<TContainerBuilder>?)

Registers a IServiceProviderFactory<TContainerBuilder> instance to be used to create the IServiceProvider.

public void ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory, Action<TContainerBuilder>? configure = null) where TContainerBuilder : notnull

Parameters

factory IServiceProviderFactory<TContainerBuilder>

The factory object that can create the TContainerBuilder and IServiceProvider.

configure Action<TContainerBuilder>

A delegate used to configure the TContainerBuilder. This can be used to configure services using APIS specific to the IServiceProviderFactory<TContainerBuilder> implementation.

Type Parameters

TContainerBuilder

The type of builder provided by the IServiceProviderFactory<TContainerBuilder>.

Remarks

The IServiceProvider is created when this builder is built and so the delegate provided by configure will run after all other services have been registered.

Multiple calls to ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>, Action<TContainerBuilder>) will replace the previously stored factory and configure delegate.