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
objectThe instance type to be returned.
viewContext
ViewContextThe 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
TypeThe instance type to be returned.
viewContext
ViewContextThe ViewContext to bind against.
Returns
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
ViewContextThe 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
TModelThs instance to be bound.
viewContext
ViewContextThe ViewContext to bind against.
Returns
- Task
The instance of
model
with its properties updated.
Type Parameters
TModel
The instance type to be returned.