This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change separates model binding into IModelBinderProvider (decides which binder to use) and IModelBinder (does binding). The IModelBinderFactory is a new services with coordinates the creation of model binders.
- Loading branch information
Showing
109 changed files
with
3,270 additions
and
2,031 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/Microsoft.AspNetCore.Mvc.Abstractions/ModelBinding/IModelBinderProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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. | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ModelBinding | ||
{ | ||
/// <summary> | ||
/// Creates <see cref="IModelBinder"/> instances. Register <see cref="IModelBinderProvider"/> | ||
/// instances in <c>MvcOptions</c>. | ||
/// </summary> | ||
public interface IModelBinderProvider | ||
{ | ||
/// <summary> | ||
/// Creates a <see cref="IModelBinder"/> based on <see cref="ModelBinderProviderContext"/>. | ||
/// </summary> | ||
/// <param name="context">The <see cref="ModelBinderProviderContext"/>.</param> | ||
/// <returns>An <see cref="IModelBinder"/>.</returns> | ||
IModelBinder GetBinder(ModelBinderProviderContext context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Microsoft.AspNetCore.Mvc.Abstractions/ModelBinding/ModelBinderProviderContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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. | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ModelBinding | ||
{ | ||
/// <summary> | ||
/// A context object for <see cref="IModelBinderProvider.GetBinder"/>. | ||
/// </summary> | ||
public abstract class ModelBinderProviderContext | ||
{ | ||
/// <summary> | ||
/// Creates an <see cref="IModelBinder"/> for the given <paramref name="metadata"/>. | ||
/// </summary> | ||
/// <param name="metadata">The <see cref="ModelMetadata"/> for the model.</param> | ||
/// <returns>An <see cref="IModelBinder"/>.</returns> | ||
public abstract IModelBinder CreateBinder(ModelMetadata metadata); | ||
|
||
/// <summary> | ||
/// Gets the <see cref="BindingInfo"/>. May be <c>null</c>. | ||
/// </summary> | ||
public abstract BindingInfo BindingInfo { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="ModelMetadata"/>. | ||
/// </summary> | ||
public abstract ModelMetadata Metadata { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="IModelMetadataProvider"/>. | ||
/// </summary> | ||
public abstract IModelMetadataProvider MetadataProvider { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.