Class BuilderBase<TBuilder, TModel>
- Namespace
- Htmx.Components.Models.Builders
- Assembly
- Htmx.Components.dll
Abstract base class for fluent builders that create model instances. Provides common functionality including dependency injection, build task management, and action context access.
public abstract class BuilderBase<TBuilder, TModel> where TBuilder : BuilderBase<TBuilder, TModel> where TModel : class
Type Parameters
TBuilder
The concrete builder type for fluent method chaining
TModel
The type of model being built
- Inheritance
-
BuilderBase<TBuilder, TModel>
- Derived
- Inherited Members
- Extension Methods
Constructors
BuilderBase(IServiceProvider)
Initializes a new instance of the BuilderBase with the specified service provider.
protected BuilderBase(IServiceProvider serviceProvider)
Parameters
serviceProvider
IServiceProviderThe service provider for dependency injection
Properties
ActionContext
Gets the current action context for the request. Provides access to request information, routing data, and action metadata.
public ActionContext ActionContext { get; }
Property Value
ServiceProvider
Gets the service provider for dependency injection. Used to resolve services needed during the build process.
public IServiceProvider ServiceProvider { get; }
Property Value
Methods
AddBuildTask(Action)
Adds a synchronous build action to be executed during the build process. The action will be wrapped in a task for consistent execution.
protected void AddBuildTask(Action action)
Parameters
action
ActionThe action to execute during building
AddBuildTask(Func<Task>)
Adds a build task from a function to be executed during the build process. Build tasks allow for asynchronous operations to be performed when creating the model.
protected void AddBuildTask(Func<Task> taskFactory)
Parameters
AddBuildTask(Task)
Adds a build task to be executed during the build process. Build tasks allow for asynchronous operations to be performed when creating the model.
protected void AddBuildTask(Task task)
Parameters
task
TaskThe task to execute during building
BuildImpl()
Builds the model instance by executing all build tasks and then calling the implementation-specific build logic. This method coordinates the entire build process and must be implemented by derived classes.
protected abstract Task<TModel> BuildImpl()
Returns
- Task<TModel>
A task that represents the asynchronous build operation, containing the built model