Example #1
0
        public Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder GetBinder(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderProviderContext context)
        {
            if (context.Metadata.ModelType != typeof(SmartAwardViewModel))
            {
                return(null);
            }
            var subclasses = new[] { typeof(GoodConductAwardViewModel), typeof(OutstandingPerformanceAwardViewModel), typeof(EmptyAwardViewModel) };
            var binders    = new Dictionary <Type, (ModelMetadata, IModelBinder)>();

            foreach (var type in subclasses)
            {
                var modelMetadata = context.MetadataProvider.GetMetadataForType(type);
                binders[type] = (modelMetadata, context.CreateBinder(modelMetadata));
            }
            return(new AwardTypeModelBinder(binders));
        }
 public IModelBinder GetBinder(ModelBinderProviderContext context)
 {
     return(_factory(context));
 }
 public IModelBinder GetBinder(ModelBinderProviderContext context)
 {
     throw new NotImplementedException();
 }