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
RequestResponse
public interface IViewModelBinder

Methods

Bind(Object, ViewContext)

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

Declaration
RequestResponse
Task Bind(object model, ViewContext viewContext)
Parameters
TypeNameDescription
System.Objectmodel

The instance type to be returned.

Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContext

The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.

Returns
TypeDescription
System.Threading.Tasks.Task

The instance of model with its properties updated.

Bind(Type, ViewContext)

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

Declaration
RequestResponse
Task<object> Bind(Type modelType, ViewContext viewContext)
Parameters
TypeNameDescription
System.TypemodelType

The instance type to be returned.

Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContext

The 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>(TModel, ViewContext)

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

Declaration
RequestResponse
Task Bind<TModel>(TModel model, ViewContext viewContext)
    where TModel : class
Parameters
TypeNameDescription
TModelmodel

Ths instance to be bound.

Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContext

The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.

Returns
TypeDescription
System.Threading.Tasks.Task

The instance of model with its properties updated.

Type Parameters
NameDescription
TModel

The instance type to be returned.

Bind<TModel>(ViewContext)

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

Declaration
RequestResponse
Task<TModel> Bind<TModel>(ViewContext viewContext)
    where TModel : class, new()
Parameters
TypeNameDescription
Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContext

The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against.

Returns
TypeDescription
System.Threading.Tasks.Task<TModel>

A bound instance of TModel or default(TModel).

Type Parameters
NameDescription
TModel

The instance type to be returned.

Do you have some feedback for us?

If you have suggestions for improving this article,