Table of Contents

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 IServiceProvider

The 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

ActionContext

ServiceProvider

Gets the service provider for dependency injection. Used to resolve services needed during the build process.

public IServiceProvider ServiceProvider { get; }

Property Value

IServiceProvider

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 Action

The 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

taskFactory Func<Task>

A function that returns the task to execute during building

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 Task

The 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