diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/BinderMetadata/ModelBinderAttribute.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/BinderMetadata/ModelBinderAttribute.cs index 3a34ac517d..bf46810a52 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/BinderMetadata/ModelBinderAttribute.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/BinderMetadata/ModelBinderAttribute.cs @@ -26,39 +26,17 @@ namespace Microsoft.AspNet.Mvc Inherited = true)] public class ModelBinderAttribute : Attribute, IModelNameProvider, IBinderTypeProviderMetadata { - private Type _binderType; private BindingSource _bindingSource; /// - public Type BinderType - { - get - { - return _binderType; - } - set - { - if (value != null) - { - if (!typeof(IModelBinder).IsAssignableFrom(value)) - { - throw new InvalidOperationException( - Resources.FormatBinderType_MustBeIModelBinder( - value.FullName, - typeof(IModelBinder).FullName)); - } - } - - _binderType = value; - } - } + public Type BinderType { get; set; } /// public BindingSource BindingSource { get { - if (_bindingSource == null && _binderType != null) + if (_bindingSource == null && BinderType != null) { return BindingSource.Custom; } diff --git a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/ModelBinderAttributeTest.cs b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/ModelBinderAttributeTest.cs index 6408b5b7ea..4200845ab1 100644 --- a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/ModelBinderAttributeTest.cs +++ b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/ModelBinderAttributeTest.cs @@ -8,23 +8,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { public class ModelBinderAttributeTest { - [Fact] - public void InvalidBinderType_Throws() - { - // Arrange - var attribute = new ModelBinderAttribute(); - - var expected = - $"The type 'System.String' must implement '{typeof(IModelBinder).FullName}' " + - "to be used as a model binder."; - - // Act - var ex = Assert.Throws(() => { attribute.BinderType = typeof(string); }); - - // Assert - Assert.Equal(expected, ex.Message); - } - [Fact] public void NoBinderType_NoBindingSource() {