Class ComponentBuilder<TComponent, TComponentBuilder>
Provides the abstract base class for the builder class of a Copper component.
Inheritance
Implements
Namespace: Copper.Common
Assembly: Copper.Common.dll
Syntax
public abstract class ComponentBuilder<TComponent, TComponentBuilder> : ComponentBuilder, IDisposable where TComponent : class where TComponentBuilder : ComponentBuilder
Type Parameters
| Name | Description |
|---|---|
| TComponent | The component type. |
| TComponentBuilder | The component builder type. |
Constructors
View SourceComponentBuilder()
Initializes a new instance of the ComponentBuilder<TComponent, TComponentBuilder> class.
Declaration
protected ComponentBuilder()
Methods
View SourceBuild()
Builds an instance of TComponent using a DI container constructed from the component builder's configuration. Calling this method more than once will result in multiple instances of TComponent, each built from a separate DI container.
Declaration
public TComponent Build()
Returns
| Type | Description |
|---|---|
| TComponent | An instance of |
BuildComponentServiceProvider()
Builds and returns a DI container based on the component builder's configuration.
Declaration
public IComponentServiceProvider BuildComponentServiceProvider()
Returns
| Type | Description |
|---|---|
| IComponentServiceProvider |
Configure(Action<IConfigurationBuilder, ConfigureServices>)
Sets up the configuration for the remainder of the build process and component. If the component builder has a parent, the configuration builder passed in is the parent component builder's configuration builder. This can be called multiple times and the results will be additive. After all calls have been processed, configuration will be updated with the results for future build steps. The resulting configuration will be available in the component builder's DI container.
Declaration
public TComponentBuilder Configure(Action<IConfigurationBuilder, ConfigureServices> configureDelegate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<IConfigurationBuilder, ConfigureServices> | configureDelegate | The delegate for configuring the |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
Configure(Action<IConfigurationBuilder>)
Sets up the configuration for the remainder of the build process and component. If the component builder has a parent, the configuration builder passed in is the parent component builder's configuration builder. This can be called multiple times and the results will be additive. After all calls have been processed, configuration will be updated with the results for future build steps. The resulting configuration will be available in the component builder's DI container.
Declaration
public TComponentBuilder Configure(Action<IConfigurationBuilder> configureDelegate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<IConfigurationBuilder> | configureDelegate | The delegate for configuring the |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
ConfigureComponentBuilderLogger(Action<ILoggingBuilder>)
Configures a logger for the remainder of the build process. This can be called multiple times and the results will be additive. If the component builder has a parent, the logger configuration passed in is the parent component builder's logger.
Declaration
public TComponentBuilder ConfigureComponentBuilderLogger(Action<ILoggingBuilder> loggerConfigurationAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<ILoggingBuilder> | loggerConfigurationAction | A delegate to configure the |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing |
|
Register(Action<IServiceCollection, RegisterServices>)
Adds services to the component builder's DI container. If the component builder has a parent, the service collection passed in is the parent component builder's service collection. This can be called multiple times and the results will be additive.
Declaration
public TComponentBuilder Register(Action<IServiceCollection, RegisterServices> registrationAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<IServiceCollection, RegisterServices> | registrationAction | The delegate for registering services on the |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
Register(Action<IServiceCollection>)
Adds services to the component builder's DI container. If the component builder has a parent, the service collection passed in is the parent component builder's service collection. This can be called multiple times and the results will be additive.
Declaration
public TComponentBuilder Register(Action<IServiceCollection> registrationAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<IServiceCollection> | registrationAction | The delegate for registering services on the |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
RegisterChildComponents(Action<IChildComponentConfigurationCollection, RegisterChildComponentsServices>)
Adds child components to the component builder's. This can be called multiple times and the results will be additive.
Declaration
public TComponentBuilder RegisterChildComponents(Action<IChildComponentConfigurationCollection, RegisterChildComponentsServices> componentConfigurationRegistrationAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<IChildComponentConfigurationCollection, RegisterChildComponentsServices> | componentConfigurationRegistrationAction | The delegate for registering child components that will be used to build the component. An instance of the child component's result type will be available in the parent component's DI container. Provides access to additional RegisterChildComponentsServices that might be useful during configuration. |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
RegisterChildComponents(Action<IChildComponentConfigurationCollection>)
Adds child components to the component builder's. This can be called multiple times and the results will be additive.
Declaration
public TComponentBuilder RegisterChildComponents(Action<IChildComponentConfigurationCollection> componentConfigurationRegistrationAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<IChildComponentConfigurationCollection> | componentConfigurationRegistrationAction | The delegate for registering child components that will be used to build the component. An instance of the child component's result type will be available in the parent component's DI container. |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |
RegisterOrReplace(String, Action<IServiceCollection>)
Registers or replaces a named registration action.
Declaration
public TComponentBuilder RegisterOrReplace(string registrationActionName, Action<IServiceCollection> registrationAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | registrationActionName | The name of the registration action. |
| System.Action<IServiceCollection> | registrationAction | The delegate for registering services on the |
Returns
| Type | Description |
|---|---|
| TComponentBuilder | The same instance of |