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
serviceProviderIServiceProviderThe service provider for resolving dependencies.
resourceOperationRegistryIResourceOperationRegistryThe 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
typeIdstringThe unique identifier for the model type.
modelUIModelUIThe 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
typeIdstringThe unique identifier for the model type.
modelUIModelUIThe 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
TThe entity type.
TKeyThe 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
typeIdstringA unique identifier for this model type registration.
configAction<IServiceProvider, ModelHandlerBuilder<T, TKey>>A configuration action that sets up the model handler builder.
Type Parameters
TThe entity type to register a handler for.
TKeyThe type of the entity's primary key.