Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
PR feedback addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
jbagga committed Feb 17, 2017
1 parent 5e13ef1 commit 1b4c30d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public void Configure(MvcOptions options)
options.ModelMetadataDetailsProviders.Add(new DefaultBindingMetadataProvider());
options.ModelMetadataDetailsProviders.Add(new DefaultValidationMetadataProvider());

options.ModelMetadataDetailsProviders.Add(new SpecialBindingSourceMetadataProvider(typeof(CancellationToken), BindingSource.Special));
options.ModelMetadataDetailsProviders.Add(new SpecialBindingSourceMetadataProvider(typeof(IFormFile), BindingSource.FormFile));
options.ModelMetadataDetailsProviders.Add(new SpecialBindingSourceMetadataProvider(typeof(IFormCollection), BindingSource.FormFile));
options.ModelMetadataDetailsProviders.Add(new BindingSourceMetadataProvider(typeof(CancellationToken), BindingSource.Special));
options.ModelMetadataDetailsProviders.Add(new BindingSourceMetadataProvider(typeof(IFormFile), BindingSource.FormFile));
options.ModelMetadataDetailsProviders.Add(new BindingSourceMetadataProvider(typeof(IFormCollection), BindingSource.FormFile));

// Set up validators
options.ModelValidatorProviders.Add(new DefaultModelValidatorProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@

namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
{
public class SpecialBindingSourceMetadataProvider : IBindingMetadataProvider
public class BindingSourceMetadataProvider : IBindingMetadataProvider
{
public Type Type { get; }
public BindingSource BindingSource { get; }

/// <summary>
/// Creates a new <see cref="SpecialBindingSourceMetadataProvider"/> for the given <paramref name="type"/>.
/// Creates a new <see cref="BindingSourceMetadataProvider"/> for the given <paramref name="type"/>.
/// </summary>
/// <param name="type">
/// The <see cref="Type"/>. The provider sets <see cref="BindingSource"/> of the given <see cref="Type"/> or
Expand All @@ -22,7 +19,7 @@ public class SpecialBindingSourceMetadataProvider : IBindingMetadataProvider
/// <param name="bindingSource">
/// The <see cref="BindingSource"/> to assign to the given <paramref name="type"/>.
/// </param>
public SpecialBindingSourceMetadataProvider(Type type, BindingSource bindingSource)
public BindingSourceMetadataProvider(Type type, BindingSource bindingSource)
{
if (type == null)
{
Expand All @@ -33,6 +30,9 @@ public SpecialBindingSourceMetadataProvider(Type type, BindingSource bindingSour
BindingSource = bindingSource;
}

public Type Type { get; }
public BindingSource BindingSource { get; }

/// <inheritdoc />
public void CreateBindingMetadata(BindingMetadataProviderContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
{
public class SpecialBindingSourceMetadataProviderTests
public class BindingSourceMetadataProviderTests
{
[Fact]
public void CreateBindingMetadata_ForMatchingType_SetsBindingSource()
{
// Arrange
var provider = new SpecialBindingSourceMetadataProvider(typeof(Test), BindingSource.Special);
var provider = new BindingSourceMetadataProvider(typeof(Test), BindingSource.Special);

var key = ModelMetadataIdentity.ForType(typeof(Test));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Microsoft.AspNetCore.Mvc.IntegrationTests
{
public class SpecialBindingSourceMetadataProviderIntegrationTest
public class BindingSourceMetadataProviderIntegrationTest
{
[Fact]
public async Task BindParameter_WithCancellationToken_BindingSourceSpecial()
Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.AspNetCore.Mvc.Test/MvcOptionsSetupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,19 @@ public void Setup_SetsUpMetadataDetailsProviders()
provider => Assert.IsType<DefaultValidationMetadataProvider>(provider),
provider =>
{
var specialParameter = Assert.IsType<SpecialBindingSourceMetadataProvider>(provider);
var specialParameter = Assert.IsType<BindingSourceMetadataProvider>(provider);
Assert.Equal(typeof(CancellationToken), specialParameter.Type);
Assert.Equal(BindingSource.Special, specialParameter.BindingSource);
},
provider =>
{
var formFileParameter = Assert.IsType<SpecialBindingSourceMetadataProvider>(provider);
var formFileParameter = Assert.IsType<BindingSourceMetadataProvider>(provider);
Assert.Equal(typeof(IFormFile), formFileParameter.Type);
Assert.Equal(BindingSource.FormFile, formFileParameter.BindingSource);
},
provider =>
{
var formCollectionParameter = Assert.IsType<SpecialBindingSourceMetadataProvider>(provider);
var formCollectionParameter = Assert.IsType<BindingSourceMetadataProvider>(provider);
Assert.Equal(typeof(IFormCollection), formCollectionParameter.Type);
Assert.Equal(BindingSource.FormFile, formCollectionParameter.BindingSource);
},
Expand Down

0 comments on commit 1b4c30d

Please sign in to comment.