diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs
deleted file mode 100644
index 2b956278b6..0000000000
--- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using Microsoft.AspNetCore.Mvc.ModelBinding.Internal;
-
-namespace Microsoft.AspNetCore.Mvc.ModelBinding
-{
- ///
- /// Extensions methods for .
- ///
- [Obsolete("This type is obsolete and will be removed in a future version. " +
- "The recommended alternative is System.ComponentModel.TypeDescriptor.GetConverter().")]
- public static class ValueProviderResultExtensions
- {
- ///
- /// Attempts to convert the values in to the specified type.
- ///
- /// The for conversion.
- /// The .
- ///
- /// The converted value, or the default value of if the value could not be converted.
- ///
- public static T ConvertTo(this ValueProviderResult result)
- {
- object valueToConvert = null;
- if (result.Values.Count == 1)
- {
- valueToConvert = result.Values[0];
- }
- else if (result.Values.Count > 1)
- {
- valueToConvert = result.Values.ToArray();
- }
- return ModelBindingHelper.ConvertTo(valueToConvert, result.Culture);
- }
-
- ///
- /// Attempts to convert the values in to the specified type.
- ///
- /// The .
- /// The for conversion.
- ///
- /// The converted value, or the default value of if the value could not be converted.
- ///
- public static object ConvertTo(this ValueProviderResult result, Type type)
- {
- if (type == null)
- {
- throw new ArgumentNullException(nameof(type));
- }
-
- object valueToConvert = null;
- if (result.Values.Count == 1)
- {
- valueToConvert = result.Values[0];
- }
- else if (result.Values.Count > 1)
- {
- valueToConvert = result.Values.ToArray();
- }
- return ModelBindingHelper.ConvertTo(valueToConvert, type, result.Culture);
- }
- }
-}
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json
index 5e4e55a0be..14c7443c38 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json
+++ b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json
@@ -2,5 +2,9 @@
{
"OldTypeId": "public class Microsoft.AspNetCore.Mvc.ProducesAttribute : Microsoft.AspNetCore.Mvc.Filters.ResultFilterAttribute, Microsoft.AspNetCore.Mvc.ApiExplorer.IApiResponseMetadataProvider",
"Kind": "Removal"
+ },
+ {
+ "OldTypeId": "public static class Microsoft.AspNetCore.Mvc.ModelBinding.ValueProviderResultExtensions",
+ "Kind": "Removal"
}
]
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json
index 5e4e55a0be..14c7443c38 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json
+++ b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json
@@ -2,5 +2,9 @@
{
"OldTypeId": "public class Microsoft.AspNetCore.Mvc.ProducesAttribute : Microsoft.AspNetCore.Mvc.Filters.ResultFilterAttribute, Microsoft.AspNetCore.Mvc.ApiExplorer.IApiResponseMetadataProvider",
"Kind": "Removal"
+ },
+ {
+ "OldTypeId": "public static class Microsoft.AspNetCore.Mvc.ModelBinding.ValueProviderResultExtensions",
+ "Kind": "Removal"
}
]
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ArrayModelBinderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ArrayModelBinderTest.cs
index 87ff8c3f29..1c41efa5ad 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ArrayModelBinderTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ArrayModelBinderTest.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc.ModelBinding.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
@@ -143,12 +144,22 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
private static IModelBinder CreateIntBinder()
{
- return new StubModelBinder(mbc =>
+ return new StubModelBinder(context =>
{
- var value = mbc.ValueProvider.GetValue(mbc.ModelName);
+ var value = context.ValueProvider.GetValue(context.ModelName);
if (value != ValueProviderResult.None)
{
- var model = value.ConvertTo(mbc.ModelType);
+ object valueToConvert = null;
+ if (value.Values.Count == 1)
+ {
+ valueToConvert = value.Values[0];
+ }
+ else if (value.Values.Count > 1)
+ {
+ valueToConvert = value.Values.ToArray();
+ }
+
+ var model = ModelBindingHelper.ConvertTo(valueToConvert, context.ModelType, value.Culture);
return ModelBindingResult.Success(model);
}
return ModelBindingResult.Failed();
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/CollectionModelBinderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/CollectionModelBinderTest.cs
index 3a0c00eaed..b11ebf38d3 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/CollectionModelBinderTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/CollectionModelBinderTest.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Internal;
+using Microsoft.AspNetCore.Mvc.ModelBinding.Internal;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Xunit;
@@ -372,15 +373,25 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
private static IModelBinder CreateIntBinder()
{
- return new StubModelBinder(mbc =>
+ return new StubModelBinder(context =>
{
- var value = mbc.ValueProvider.GetValue(mbc.ModelName);
+ var value = context.ValueProvider.GetValue(context.ModelName);
if (value == ValueProviderResult.None)
{
return ModelBindingResult.Failed();
}
- var model = value.ConvertTo(mbc.ModelType);
+ object valueToConvert = null;
+ if (value.Values.Count == 1)
+ {
+ valueToConvert = value.Values[0];
+ }
+ else if (value.Values.Count > 1)
+ {
+ valueToConvert = value.Values.ToArray();
+ }
+
+ var model = ModelBindingHelper.ConvertTo(valueToConvert, context.ModelType, value.Culture);
if (model == null)
{
return ModelBindingResult.Failed();