Table of Contents

Class ModelRegistry

Namespace
Htmx.Components.Services
Assembly
Htmx.Components.dll

Implements model handler registration and retrieval functionality. This class manages a registry of model handlers and provides lazy initialization of handlers when requested.

public class ModelRegistry : IModelRegistry
Inheritance
ModelRegistry
Implements
Inherited Members
Extension Methods

Constructors

ModelRegistry(IServiceProvider, IResourceOperationRegistry)

Initializes a new instance of the ModelRegistry class.

public ModelRegistry(IServiceProvider serviceProvider, IResourceOperationRegistry resourceOperationRegistry)

Parameters

serviceProvider IServiceProvider

The service provider for resolving dependencies.

resourceOperationRegistry IResourceOperationRegistry

The registry for authorization resource operations.

Methods

GetModelHandler(string, ModelUI)

Retrieves a model handler for the specified type identifier and UI configuration.

public Task<ModelHandler> GetModelHandler(string typeId, ModelUI modelUI)

Parameters

typeId string

The unique identifier for the model type.

modelUI ModelUI

The 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.

public Task<ModelHandler<T, TKey>> GetModelHandler<T, TKey>(string typeId, ModelUI modelUI) where T : class

Parameters

typeId string

The unique identifier for the model type.

modelUI ModelUI

The 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. The handler is built using the provided configuration and stored for later retrieval.

public void Register<T, TKey>(string typeId, Action<IServiceProvider, ModelHandlerBuilder<T, TKey>> config) where T : class, new()

Parameters

typeId string

A 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.