Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

NopModelBinderProvider.cs

using Microsoft.AspNetCore.Mvc.ModelBinding;
using Nop.Web.Framework.Models;

namespace Nop.Web.Framework.Mvc.ModelBinding.Binders;

/// 
/// Represents a model binder provider for specific properties
/// 
public partial class NopModelBinderProvider : IModelBinderProvider
{
    IModelBinder IModelBinderProvider.GetBinder(ModelBinderProviderContext context)
    {
        if (context.Metadata.PropertyName == nameof(BaseNopModel.CustomProperties) && context.Metadata.ModelType == typeof(Dictionary))
            return new CustomPropertiesModelBinder();

        if (!context.Metadata.IsComplexType && context.Metadata.ModelType == typeof(string)) 
            return new StringModelBinder();

        return null;
    }
}