Class BindingExtensions

Version: 21.x

Extensions to support model binding for Sitecore layout data.

Inheritance
System.Object
BindingExtensions
Namespace: Sitecore.AspNet.RenderingEngine.Binding.Extensions
Assembly: Sitecore.AspNet.RenderingEngine.dll
Syntax
RequestResponse
public static class BindingExtensions : Object

Methods

AddSitecoreModelBinderProviders(MvcOptions)

Adds the default Sitecore model binder providers to the Microsoft.AspNetCore.Mvc.MvcOptions.

Declaration
RequestResponse
public static void AddSitecoreModelBinderProviders(this MvcOptions options)
Parameters
TypeNameDescription
Microsoft.AspNetCore.Mvc.MvcOptionsoptions

The Microsoft.AspNetCore.Mvc.MvcOptions to configure.

GetModelBinder<TSource>(ModelBinderProviderContext)

Gets the SitecoreLayoutModelBinder<T> for the specified binding source.

Declaration
RequestResponse
public static BinderTypeModelBinder GetModelBinder<TSource>(this ModelBinderProviderContext context)
    where TSource : SitecoreLayoutBindingSource
Parameters
TypeNameDescription
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContextcontext

The Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContext instance.

Returns
TypeDescription
Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder

The Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder instance.

Type Parameters
NameDescription
TSource

The type of the binding source.

GetModelBinder<TSource, TType>(ModelBinderProviderContext)

Gets the SitecoreLayoutModelBinder<T> for the specified model type and binding source.

Declaration
RequestResponse
public static BinderTypeModelBinder GetModelBinder<TSource, TType>(this ModelBinderProviderContext context)
    where TSource : SitecoreLayoutBindingSource
Parameters
TypeNameDescription
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContextcontext

The Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContext instance.

Returns
TypeDescription
Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder

The Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder instance.

Type Parameters
NameDescription
TSource

The type of the binding source.

TType

The model type to bind to.

Do you have some feedback for us?

If you have suggestions for improving this article,