Interface IViewModelBinder

Version: 21.x

Contract that allows models to be bound based on a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.

Namespace: Sitecore.AspNet.RenderingEngine.Binding

Assembly: Sitecore.AspNet.RenderingEngine.Abstractions.dll

Syntax

public interface IViewModelBinder

Methods

Bind(Object, ViewContext)

Binds properties on the given model based on the given viewContext.

Declaration
Task Bind(object model, ViewContext viewContext)
Parameters
TypeNameDescription
System.ObjectmodelThe instance type to be returned.
Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContextThe Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.
Returns
TypeDescription
System.Threading.Tasks.TaskThe instance of model with its properties updated.

Bind(Type, ViewContext)

Binds properties on the given modelType based on the given viewContext.

Declaration
Task<object> Bind(Type modelType, ViewContext viewContext)
Parameters
TypeNameDescription
System.TypemodelTypeThe instance type to be returned.
Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContextThe Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.
Returns
TypeDescription
System.Threading.Tasks.Task

<

System.Object

>
The instance of modelType with its properties updated.

Bind(TModel, ViewContext)

Binds properties on the given model based on the given viewContext.

Declaration

Task Bind<TModel>(TModel model, ViewContext viewContext)
    where TModel : class

Parameters
TypeNameDescription
TModelmodelThs instance to be bound.
Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContextThe Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.
Returns
TypeDescription
System.Threading.Tasks.TaskThe instance of model with its properties updated.
Type Parameters
NameDescription
TModelThe instance type to be returned.

Bind(ViewContext)

Creates an instance of TModel and binds properties based on the given viewContext.

Declaration

Task<TModel> Bind<TModel>(ViewContext viewContext)
    where TModel : class, new()

Parameters
TypeNameDescription
Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContextThe Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.
Returns
TypeDescription
System.Threading.Tasks.Task

A bound instance of TModel or default(TModel).
Type Parameters
NameDescription
TModelThe instance type to be returned.
If you have suggestions for improving this article, let us know!