Try our conversational search powered by Generative AI!

Class TemplateModelComparer

Default implementation of ITemplateModelComparer. The implementation will look in the inheritance chain for where IRenderTemplate<TModel> is implemented. And then compare the generic types in the inheritance chain and sort so the model with "shortest" inheritance is inserted before in list. In case IRenderTemplate<TModel> is not found (e.g. when explicitly registered partial MVC view) then that is inserted before in list.

Inheritance
System.Object
TemplateModelComparer
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.RuntimeModel
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
[Obsolete("Deprecated and replaced by use of standard IComparer<>")]
[ServiceConfiguration(typeof(ITemplateModelComparer))]
public class TemplateModelComparer : ITemplateModelComparer

Constructors

TemplateModelComparer(TypeRelater)

Creates a new instance of the TemplateModelComparer class.

Declaration
public TemplateModelComparer(TypeRelater typeRelater)
Parameters
Type Name Description
TypeRelater typeRelater

The type relater.

Methods

Compare(TemplateModel, TemplateModel, Type)

Compares two TemplateModel instances to determine their sort order for modelType. The implementation should follow: Return less than zero: x is "closer" to modelType than y. That is inserted before y in list. Return zero: x is equally close to modelType that y. In this case x gets after y in list. Return greater than zero: y is "closer" to modelType than x. That is x is inserted after y in list.

Declaration
public virtual int Compare(TemplateModel newModel, TemplateModel currentModel, Type modelType)
Parameters
Type Name Description
TemplateModel newModel

The new model.

TemplateModel currentModel

The current model.

System.Type modelType

Type of the model.

Returns
Type Description
System.Int32

Implements

Extension Methods