Class ModelHandlerFactory
- Namespace
 - Htmx.Components.Services
 
- Assembly
 - Htmx.Components.dll
 
Provides a factory interface for creating model handlers without direct dependency on the model registry. This factory helps avoid dependency injection recursion issues when injecting into controllers.
public class ModelHandlerFactory : IModelHandlerFactory, IModelHandlerFactoryGeneric
  - Inheritance
 - 
      
      ModelHandlerFactory
 
- Implements
 
- Inherited Members
 
- Extension Methods
 
Remarks
Controllers should inject this interface rather than IModelRegistry directly to prevent circular dependency issues in the DI container.
Constructors
ModelHandlerFactory(IServiceProvider)
Initializes a new instance of the ModelHandlerFactory class.
public ModelHandlerFactory(IServiceProvider serviceProvider)
  Parameters
serviceProviderIServiceProviderThe service provider for resolving the model registry.
Methods
Get(string, ModelUI)
Creates a model handler for the specified type identifier and UI configuration.
public Task<ModelHandler> Get(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.
Get<T, TKey>(string, ModelUI)
Creates a strongly-typed model handler for the specified type identifier and UI configuration.
public Task<ModelHandler<T, TKey>> Get<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.