HostBuilder class

A program initialization abstraction.

Implementers
Available extensions

Constructors

HostBuilder.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
properties Map<Object, Object>
A central location for sharing state between components during the host building process.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build() Host
Run the given actions to initialize the host. This can only be called once.
configureAppConfiguration(ConfigureAppConfigurationDelegate configureDelegate) HostBuilder
Sets up the configuration for the remainder of the build process and application. This can be called multiple times and the results will be additive. The results will be available at Configuration for subsequent operations, as well as in services.
configureContainer<TContainerBuilder>(ConfigureContainerAdapterDelegate<TContainerBuilder> configureDelegate) HostBuilder
Enables configuring the instantiated dependency container. This can be called multiple times and the results will be additive.
configureDefaults([List<String>? args]) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Configures an existing HostBuilder instance with pre-configured defaults.
configureHostConfiguration(ConfigureHostConfigurationDelegate configureDelegate) HostBuilder
Set up the configuration for the builder itself. This will be used to initialize the HostEnvironment for use later in the build process. This can be called multiple times and the results will be additive.
configureHostOptions(void configureOptions(HostBuilderContext context, HostOptions options)) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Adds a delegate for configuring the HostOptions of the Host.
configureLogging(void configure(HostBuilderContext context, LoggingBuilder logging)) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Adds a delegate for configuring the provided LoggingBuilder. This may be called multiple times.
configureServices(ConfigureServicesDelegate configureDelegate) HostBuilder
Adds services to the container. This can be called multiple times and the results will be additive.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runConsole([CancellationToken? cancellationToken]) Future<void>

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.
start({CancellationToken? cancellationToken}) Future<Host>

Available on HostBuilder, provided by the HostingAbstractionsHostBuilderExtensions extension

Builds and starts the host.
toString() String
A string representation of this object.
inherited
useConsoleLifetime([void configure(ConsoleLifetimeOptions options)?]) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Listens for Ctrl+C or SIGTERM and calls HostApplicationLifetime.stopApplication to start the shutdown process. This will unblock extensions like RunAsync and WaitForShutdownAsync.
useContentRoot(String contentRoot) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Specify the content root directory to be used by the host.
useDefaultServiceProvider(ConfigureDefaultServiceProvider configure) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Specify the ServiceProvider to be the default one.
useEnvironment(String environment) HostBuilder

Available on HostBuilder, provided by the HostingHostBuilderExtensions extension

Specify the environment to be used by the host.
useServiceProviderFactory<TContainerBuilder>({ServiceProviderFactory<TContainerBuilder>? implementation, FactoryResolver<TContainerBuilder>? factory}) HostBuilder
Overrides the factory used to create the service provider.

Operators

operator ==(Object other) bool
The equality operator.
inherited