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
Implements
Inherited Members
Namespace: EPiServer.DataAbstraction.RuntimeModel
Assembly: EPiServer.dll
Version: 8.11.0Syntax
[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 |