Interface IModelRegistry
- Namespace
- Htmx.Components.Services
- Assembly
- Htmx.Components.dll
Provides a contract for registering and retrieving model handlers for different entity types. Model handlers define how entities are displayed, edited, and managed in the UI.
public interface IModelRegistry
- Extension Methods
Methods
GetModelHandler(string, ModelUI)
Retrieves a model handler for the specified type identifier and UI configuration.
Task<ModelHandler> GetModelHandler(string typeId, ModelUI modelUI)
Parameters
typeId
stringThe unique identifier for the model type.
modelUI
ModelUIThe UI configuration for the model.
Returns
- Task<ModelHandler>
A task that represents the asynchronous operation. The task result contains the model handler.
Exceptions
- InvalidOperationException
Thrown when no model handler is found for the specified type identifier.
GetModelHandler<T, TKey>(string, ModelUI)
Retrieves a strongly-typed model handler for the specified type identifier and UI configuration.
Task<ModelHandler<T, TKey>> GetModelHandler<T, TKey>(string typeId, ModelUI modelUI) where T : class
Parameters
typeId
stringThe unique identifier for the model type.
modelUI
ModelUIThe UI configuration for the model.
Returns
- Task<ModelHandler<T, TKey>>
A task that represents the asynchronous operation. The task result contains the strongly-typed model handler.
Type Parameters
T
The entity type.
TKey
The type of the entity's primary key.
Exceptions
- InvalidOperationException
Thrown when no model handler is found for the specified type identifier, or when the handler is not of the expected type.
Register<T, TKey>(string, Action<IServiceProvider, ModelHandlerBuilder<T, TKey>>)
Registers a model handler for the specified entity type with configuration logic.
void Register<T, TKey>(string typeId, Action<IServiceProvider, ModelHandlerBuilder<T, TKey>> config) where T : class, new()
Parameters
typeId
stringA unique identifier for this model type registration.
config
Action<IServiceProvider, ModelHandlerBuilder<T, TKey>>A configuration action that sets up the model handler builder.
Type Parameters
T
The entity type to register a handler for.
TKey
The type of the entity's primary key.