Table of Contents

Interface IViewModelBinder

Namespace
Sitecore.AspNetCore.SDK.RenderingEngine.Binding
Assembly
Sitecore.AspNetCore.SDK.RenderingEngine.dll

Contract that allows models to be bound based on a ViewContext.

public interface IViewModelBinder

Methods

Bind(object, ViewContext)

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

Task Bind(object model, ViewContext viewContext)

Parameters

model object

The instance type to be returned.

viewContext ViewContext

The ViewContext to bind against.

Returns

Task

The instance of model with its properties updated.

Bind(Type, ViewContext)

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

Task<object> Bind(Type modelType, ViewContext viewContext)

Parameters

modelType Type

The instance type to be returned.

viewContext ViewContext

The ViewContext to bind against.

Returns

Task<object>

The instance of modelType with its properties updated.

Bind<TModel>(ViewContext)

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

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

Parameters

viewContext ViewContext

The ViewContext to bind against.

Returns

Task<TModel>

A bound instance of TModel or default(TModel).

Type Parameters

TModel

The instance type to be returned.

Bind<TModel>(TModel, ViewContext)

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

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

Parameters

model TModel

Ths instance to be bound.

viewContext ViewContext

The ViewContext to bind against.

Returns

Task

The instance of model with its properties updated.

Type Parameters

TModel

The instance type to be returned.