CustomerModelBinderProvider.cs 805 B

12345678910111213141516171819202122232425262728
  1. using GreenTree.Strohrmann.ERP.Web.Models.Business;
  2. using Microsoft.AspNetCore.Mvc.ModelBinding;
  3. using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. namespace GreenTree.Strohrmann.ERP.Web.Models
  9. {
  10. public class CustomerModelBinderProvider : IModelBinderProvider
  11. {
  12. public IModelBinder GetBinder(ModelBinderProviderContext context)
  13. {
  14. if (context == null)
  15. {
  16. throw new ArgumentNullException(nameof(context));
  17. }
  18. if (context.Metadata.ModelType == typeof(CustomerModel))
  19. {
  20. return new BinderTypeModelBinder(typeof(CustomerModelBinder));
  21. }
  22. return null;
  23. }
  24. }
  25. }