Try our conversational search powered by Generative AI!

Class TemplateModelRepository

Repository for template information objects for render templates.

Inheritance
System.Object
TemplateModelRepository
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
[ServiceConfiguration(Lifecycle = ServiceInstanceScope.Singleton)]
public class TemplateModelRepository
Remarks

The repository is registered as Singleton in IOC container meaning you should not create new instances directly but instead get instance from IOC container or preferably have it as a dependency in constructor and let the container create instances of the dependent class.

Constructors

TemplateModelRepository()

Initializes a new instance of the TemplateModelRepository class.

Declaration
public TemplateModelRepository()

TemplateModelRepository(TemplateModelComparerFactory)

Initializes a new instance of the TemplateModelRepository class.

Declaration
public TemplateModelRepository(TemplateModelComparerFactory comparerFactory)
Parameters
Type Name Description
TemplateModelComparerFactory comparerFactory

The comparer factory.

Methods

List(Type)

Gets all TemplateModel for a type.

Declaration
public virtual IEnumerable<TemplateModel> List(Type modelType)
Parameters
Type Name Description
System.Type modelType

Type of the model.

Returns
Type Description
System.Collections.Generic.IEnumerable<TemplateModel>

OnModelTypeTemplatesChanged(Type)

Called when a change is done to the templates of the specified model type.

Declaration
[Obsolete("Event is raised inconsistently and will be removed in a future release.")]
protected virtual void OnModelTypeTemplatesChanged(Type modelType)
Parameters
Type Name Description
System.Type modelType

Type of the model where the changes was made to.

RegisterModelType(Type)

Registers a model type to the repository.

Declaration
public virtual void RegisterModelType(Type modelType)
Parameters
Type Name Description
System.Type modelType

Type of the model.

Remarks

During registration the inheritance chain will be traversed for TemplateModel that are registered for base types and marked as Inherited.

RegisterTemplate(Type, TemplateModel[])

Registers one or many templates for the provided model type.

Declaration
public virtual void RegisterTemplate(Type modelType, params TemplateModel[] templates)
Parameters
Type Name Description
System.Type modelType

Type of the model that the template should be registered for.

TemplateModel[] templates

The templates that should be registered.

UnregisterTemplate(Type, TemplateModel)

Removes a TemplateModel that has been registered for the specified model type.

Declaration
public virtual bool UnregisterTemplate(Type modelType, TemplateModel template)
Parameters
Type Name Description
System.Type modelType

Type of the model.

TemplateModel template

The template model that should be removed.

Returns
Type Description
System.Boolean

true if the TemplateModel existed and was removed, if it not existed false is returned

Events

ModelTypeTemplatesChanged

Occurs when a change is done to the templates of a given model type.

Declaration
[Obsolete("Event is raised inconsistently and will be removed in a future release.")]
public event EventHandler<ModelRepositoryEventArgs> ModelTypeTemplatesChanged
Event Type
Type Description
System.EventHandler<ModelRepositoryEventArgs>

Extension Methods