parent
9e2f8b7cb5
commit
b4fe715c71
|
|
@ -1,57 +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 System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of application model conventions.
|
||||
/// </summary>
|
||||
public class ApplicationModelConventionCollection : Collection<IApplicationModelConvention>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApplicationModelConventionCollection"/> class that is empty.
|
||||
/// </summary>
|
||||
public ApplicationModelConventionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApplicationModelConventionCollection"/> class
|
||||
/// as a wrapper for the specified list.
|
||||
/// </summary>
|
||||
/// <param name="applicationModelConventions">The list that is wrapped by the new collection.</param>
|
||||
public ApplicationModelConventionCollection(IList<IApplicationModelConvention> applicationModelConventions)
|
||||
: base(applicationModelConventions)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all application model conventions of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TApplicationModelConvention">The type to remove.</typeparam>
|
||||
public void RemoveType<TApplicationModelConvention>() where TApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
RemoveType(typeof(TApplicationModelConvention));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all application model conventions of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="applicationModelConventionType">The type to remove.</param>
|
||||
public void RemoveType(Type applicationModelConventionType)
|
||||
{
|
||||
for (var i = Count - 1; i >= 0; i--)
|
||||
{
|
||||
var applicationModelConvention = this[i];
|
||||
if (applicationModelConvention.GetType() == applicationModelConventionType)
|
||||
{
|
||||
RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,48 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
/// </summary>
|
||||
public static class ApplicationModelConventionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all application model conventions of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IApplicationModelConvention"/>s.</param>
|
||||
/// <typeparam name="TApplicationModelConvention">The type to remove.</typeparam>
|
||||
public static void RemoveType<TApplicationModelConvention>(this IList<IApplicationModelConvention> list) where TApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
RemoveType(list, typeof(TApplicationModelConvention));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all application model conventions of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IApplicationModelConvention"/>s.</param>
|
||||
/// <param name="type">The type to remove.</param>
|
||||
public static void RemoveType(this IList<IApplicationModelConvention> list, Type type)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var applicationModelConvention = list[i];
|
||||
if (applicationModelConvention.GetType() == type)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="IControllerModelConvention"/> to all the controllers in the application.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,57 +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 System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of metadata details providers.
|
||||
/// </summary>
|
||||
public class MetadataDetailsProviderCollection : Collection<IMetadataDetailsProvider>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MetadataDetailsProviderCollection"/> class that is empty.
|
||||
/// </summary>
|
||||
public MetadataDetailsProviderCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MetadataDetailsProviderCollection"/> class
|
||||
/// as a wrapper for the specified list.
|
||||
/// </summary>
|
||||
/// <param name="metadataDetailsProviders">The list that is wrapped by the new collection.</param>
|
||||
public MetadataDetailsProviderCollection(IList<IMetadataDetailsProvider> metadataDetailsProviders)
|
||||
: base(metadataDetailsProviders)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all metadata details providers of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TMetadataDetailsProvider">The type to remove.</typeparam>
|
||||
public void RemoveType<TMetadataDetailsProvider>() where TMetadataDetailsProvider : IMetadataDetailsProvider
|
||||
{
|
||||
RemoveType(typeof(TMetadataDetailsProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all metadata details providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="metadataDetailsProviderType">The type to remove.</param>
|
||||
public void RemoveType(Type metadataDetailsProviderType)
|
||||
{
|
||||
for (var i = Count - 1; i >= 0; i--)
|
||||
{
|
||||
var metadataDetailsProvider = this[i];
|
||||
if (metadataDetailsProvider.GetType() == metadataDetailsProviderType)
|
||||
{
|
||||
RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// 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 System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="IMetadataDetailsProvider"/>.
|
||||
/// </summary>
|
||||
public static class MetadataDetailsProviderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all metadata details providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IMetadataDetailsProvider"/>s.</param>
|
||||
/// <typeparam name="TMetadataDetailsProvider">The type to remove.</typeparam>
|
||||
public static void RemoveType<TMetadataDetailsProvider>(this IList<IMetadataDetailsProvider> list) where TMetadataDetailsProvider : IMetadataDetailsProvider
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
RemoveType(list, typeof(TMetadataDetailsProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all metadata details providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IMetadataDetailsProvider"/>s.</param>
|
||||
/// <param name="type">The type to remove.</param>
|
||||
public static void RemoveType(this IList<IMetadataDetailsProvider> list, Type type)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var metadataDetailsProvider = list[i];
|
||||
if (metadataDetailsProvider.GetType() == type)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +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 System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of model binder providers.
|
||||
/// </summary>
|
||||
public class ModelBinderProviderCollection : Collection<IModelBinderProvider>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelBinderProviderCollection"/> class that is empty.
|
||||
/// </summary>
|
||||
public ModelBinderProviderCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelBinderProviderCollection"/> class
|
||||
/// as a wrapper for the specified list.
|
||||
/// </summary>
|
||||
/// <param name="modelBinderProviders">The list that is wrapped by the new collection.</param>
|
||||
public ModelBinderProviderCollection(IList<IModelBinderProvider> modelBinderProviders)
|
||||
: base(modelBinderProviders)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all model binder providers of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModelBinderProvider">The type to remove.</typeparam>
|
||||
public void RemoveType<TModelBinderProvider>() where TModelBinderProvider : IModelBinderProvider
|
||||
{
|
||||
RemoveType(typeof(TModelBinderProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all model binder providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="modelBinderProviderType">The type to remove.</param>
|
||||
public void RemoveType(Type modelBinderProviderType)
|
||||
{
|
||||
for (var i = Count - 1; i >= 0; i--)
|
||||
{
|
||||
var modelBinderProvider = this[i];
|
||||
if (modelBinderProvider.GetType() == modelBinderProviderType)
|
||||
{
|
||||
RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// 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 System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="IModelBinderProvider"/>.
|
||||
/// </summary>
|
||||
public static class ModelBinderProviderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all model binder providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IModelBinderProvider"/>s.</param>
|
||||
/// <typeparam name="TModelBinderProvider">The type to remove.</typeparam>
|
||||
public static void RemoveType<TModelBinderProvider>(this IList<IModelBinderProvider> list) where TModelBinderProvider : IModelBinderProvider
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
RemoveType(list, typeof(TModelBinderProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all model binder providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IModelBinderProvider"/>s.</param>
|
||||
/// <param name="type">The type to remove.</param>
|
||||
public static void RemoveType(this IList<IModelBinderProvider> list, Type type)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var modelBinderProvider = list[i];
|
||||
if (modelBinderProvider.GetType() == type)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +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 System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of model validator providers.
|
||||
/// </summary>
|
||||
public class ModelValidatorProviderCollection : Collection<IModelValidatorProvider>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelValidatorProviderCollection"/> class that is empty.
|
||||
/// </summary>
|
||||
public ModelValidatorProviderCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelValidatorProviderCollection"/> class
|
||||
/// as a wrapper for the specified list.
|
||||
/// </summary>
|
||||
/// <param name="modelValidatorProviders">The list that is wrapped by the new collection.</param>
|
||||
public ModelValidatorProviderCollection(IList<IModelValidatorProvider> modelValidatorProviders)
|
||||
: base(modelValidatorProviders)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all model validator providers of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModelValidatorProvider">The type to remove.</typeparam>
|
||||
public void RemoveType<TModelValidatorProvider>() where TModelValidatorProvider : IModelValidatorProvider
|
||||
{
|
||||
RemoveType(typeof(TModelValidatorProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all model validator providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="modelValidatorProviderType">The type to remove.</param>
|
||||
public void RemoveType(Type modelValidatorProviderType)
|
||||
{
|
||||
for (var i = Count - 1; i >= 0; i--)
|
||||
{
|
||||
var modelValidatorProvider = this[i];
|
||||
if (modelValidatorProvider.GetType() == modelValidatorProviderType)
|
||||
{
|
||||
RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// 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 System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="IModelValidatorProvider"/>.
|
||||
/// </summary>
|
||||
public static class ModelValidatorProviderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all model validator providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">This list of <see cref="IModelValidatorProvider"/>s.</param>
|
||||
/// <typeparam name="TModelValidatorProvider">The type to remove.</typeparam>
|
||||
public static void RemoveType<TModelValidatorProvider>(this IList<IModelValidatorProvider> list) where TModelValidatorProvider : IModelValidatorProvider
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
RemoveType(list, typeof(TModelValidatorProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all model validator providers of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">This list of <see cref="IModelValidatorProvider"/>s.</param>
|
||||
/// <param name="type">The type to remove.</param>
|
||||
public static void RemoveType(this IList<IModelValidatorProvider> list, Type type)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var modelValidatorProvider = list[i];
|
||||
if (modelValidatorProvider.GetType() == type)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +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 System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of value provider factories.
|
||||
/// </summary>
|
||||
public class ValueProviderFactoryCollection : Collection<IValueProviderFactory>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ValueProviderFactoryCollection"/> class that is empty.
|
||||
/// </summary>
|
||||
public ValueProviderFactoryCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ValueProviderFactoryCollection"/> class
|
||||
/// as a wrapper for the specified list.
|
||||
/// </summary>
|
||||
/// <param name="valueProviderFactories">The list that is wrapped by the new collection.</param>
|
||||
public ValueProviderFactoryCollection(IList<IValueProviderFactory> valueProviderFactories)
|
||||
: base(valueProviderFactories)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all value provider factories of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TValueProviderFactory">The type to remove.</typeparam>
|
||||
public void RemoveType<TValueProviderFactory>() where TValueProviderFactory : IValueProviderFactory
|
||||
{
|
||||
RemoveType(typeof(TValueProviderFactory));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all value provider factories of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="valueProviderFactoryType">The type to remove.</param>
|
||||
public void RemoveType(Type valueProviderFactoryType)
|
||||
{
|
||||
for (var i = Count - 1; i >= 0; i--)
|
||||
{
|
||||
var valueProviderFactory = this[i];
|
||||
if (valueProviderFactory.GetType() == valueProviderFactoryType)
|
||||
{
|
||||
RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// 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 System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="IValueProviderFactory"/>.
|
||||
/// </summary>
|
||||
public static class ValueProviderFactoryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all value provider factories of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IValueProviderFactory"/>.</param>
|
||||
/// <typeparam name="TValueProviderFactory">The type to remove.</typeparam>
|
||||
public static void RemoveType<TValueProviderFactory>(this IList<IValueProviderFactory> list) where TValueProviderFactory : IValueProviderFactory
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
RemoveType(list, typeof(TValueProviderFactory));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all value provider factories of the specified type.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of <see cref="IValueProviderFactory"/>.</param>
|
||||
/// <param name="type">The type to remove.</param>
|
||||
public static void RemoveType(this IList<IValueProviderFactory> list, Type type)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var valueProviderFactory = list[i];
|
||||
if (valueProviderFactory.GetType() == type)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,16 +22,16 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public MvcOptions()
|
||||
{
|
||||
CacheProfiles = new Dictionary<string, CacheProfile>(StringComparer.OrdinalIgnoreCase);
|
||||
Conventions = new ApplicationModelConventionCollection();
|
||||
Conventions = new List<IApplicationModelConvention>();
|
||||
Filters = new FilterCollection();
|
||||
FormatterMappings = new FormatterMappings();
|
||||
InputFormatters = new FormatterCollection<IInputFormatter>();
|
||||
OutputFormatters = new FormatterCollection<IOutputFormatter>();
|
||||
ModelBinderProviders = new ModelBinderProviderCollection();
|
||||
ModelBinderProviders = new List<IModelBinderProvider>();
|
||||
ModelBindingMessageProvider = new DefaultModelBindingMessageProvider();
|
||||
ModelMetadataDetailsProviders = new MetadataDetailsProviderCollection();
|
||||
ModelValidatorProviders = new ModelValidatorProviderCollection();
|
||||
ValueProviderFactories = new ValueProviderFactoryCollection();
|
||||
ModelMetadataDetailsProviders = new List<IMetadataDetailsProvider>();
|
||||
ModelValidatorProviders = new List<IModelValidatorProvider>();
|
||||
ValueProviderFactories = new List<IValueProviderFactory>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// Gets a list of <see cref="IApplicationModelConvention"/> instances that will be applied to
|
||||
/// the <see cref="ApplicationModel"/> when discovering actions.
|
||||
/// </summary>
|
||||
public ApplicationModelConventionCollection Conventions { get; }
|
||||
public IList<IApplicationModelConvention> Conventions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="IFilterMetadata"/> which are used to construct filters that
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets a list of <see cref="IModelBinderProvider"/>s used by this application.
|
||||
/// </summary>
|
||||
public ModelBinderProviderCollection ModelBinderProviders { get; }
|
||||
public IList<IModelBinderProvider> ModelBinderProviders { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default <see cref="ModelBinding.Metadata.ModelBindingMessageProvider"/>. Changes here are copied to the
|
||||
|
|
@ -122,12 +122,12 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <li><see cref="IValidationMetadataProvider"/></li>
|
||||
/// </ul>
|
||||
/// </remarks>
|
||||
public MetadataDetailsProviderCollection ModelMetadataDetailsProviders { get; }
|
||||
public IList<IMetadataDetailsProvider> ModelMetadataDetailsProviders { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="IModelValidatorProvider"/>s used by this application.
|
||||
/// </summary>
|
||||
public ModelValidatorProviderCollection ModelValidatorProviders { get; }
|
||||
public IList<IModelValidatorProvider> ModelValidatorProviders { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="IOutputFormatter"/>s that are used by this application.
|
||||
|
|
@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets a list of <see cref="IValueProviderFactory"/> used by this application.
|
||||
/// </summary>
|
||||
public ValueProviderFactoryCollection ValueProviderFactories { get; }
|
||||
public IList<IValueProviderFactory> ValueProviderFactories { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the SSL port that is used by this application when <see cref="RequireHttpsAttribute"/>
|
||||
|
|
|
|||
|
|
@ -145,30 +145,5 @@
|
|||
"TypeId": "public class Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata : Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata",
|
||||
"MemberId": "public override Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IModelBindingMessageProvider get_ModelBindingMessageProvider()",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Mvc.MvcOptions",
|
||||
"MemberId": "public System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.ApplicationModels.IApplicationModelConvention> get_Conventions()",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Mvc.MvcOptions",
|
||||
"MemberId": "public System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderProvider> get_ModelBinderProviders()",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Mvc.MvcOptions",
|
||||
"MemberId": "public System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.ModelBinding.IValueProviderFactory> get_ValueProviderFactories()",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Mvc.MvcOptions",
|
||||
"MemberId": "public System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IMetadataDetailsProvider> get_ModelMetadataDetailsProviders()",
|
||||
"Kind": "Removal"
|
||||
},
|
||||
{
|
||||
"TypeId": "public class Microsoft.AspNetCore.Mvc.MvcOptions",
|
||||
"MemberId": "public System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IModelValidatorProvider> get_ModelValidatorProviders()",
|
||||
"Kind": "Removal"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,66 +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 System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
||||
{
|
||||
public class ApplicationModelConventionCollectionTests
|
||||
{
|
||||
[Fact]
|
||||
public void RemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ApplicationModelConventionCollection
|
||||
{
|
||||
new FooApplicationModelConvention(),
|
||||
new BarApplicationModelConvention(),
|
||||
new FooApplicationModelConvention()
|
||||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType(typeof(FooApplicationModelConvention));
|
||||
|
||||
// Assert
|
||||
var convention = Assert.Single(collection);
|
||||
Assert.IsType<BarApplicationModelConvention>(convention);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenericRemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ApplicationModelConventionCollection
|
||||
{
|
||||
new FooApplicationModelConvention(),
|
||||
new BarApplicationModelConvention(),
|
||||
new FooApplicationModelConvention()
|
||||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType<FooApplicationModelConvention>();
|
||||
|
||||
// Assert
|
||||
var convention = Assert.Single(collection);
|
||||
Assert.IsType<BarApplicationModelConvention>(convention);
|
||||
}
|
||||
|
||||
private class FooApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
public void Apply(ApplicationModel application)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class BarApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
public void Apply(ApplicationModel application)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
// 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 System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
|
|
@ -89,6 +89,60 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var list = new List<IApplicationModelConvention>
|
||||
{
|
||||
new FooApplicationModelConvention(),
|
||||
new BarApplicationModelConvention(),
|
||||
new FooApplicationModelConvention()
|
||||
};
|
||||
|
||||
// Act
|
||||
list.RemoveType(typeof(FooApplicationModelConvention));
|
||||
|
||||
// Assert
|
||||
var convention = Assert.Single(list);
|
||||
Assert.IsType<BarApplicationModelConvention>(convention);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenericRemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var list = new List<IApplicationModelConvention>
|
||||
{
|
||||
new FooApplicationModelConvention(),
|
||||
new BarApplicationModelConvention(),
|
||||
new FooApplicationModelConvention()
|
||||
};
|
||||
|
||||
// Act
|
||||
list.RemoveType<FooApplicationModelConvention>();
|
||||
|
||||
// Assert
|
||||
var convention = Assert.Single(list);
|
||||
Assert.IsType<BarApplicationModelConvention>(convention);
|
||||
}
|
||||
|
||||
private class FooApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
public void Apply(ApplicationModel application)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class BarApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
public void Apply(ApplicationModel application)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class HelloController
|
||||
{
|
||||
public string GetHello()
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
// 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 System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||
{
|
||||
public class MetadataDetailsProviderCollectionTests
|
||||
public class MetadataDetailsProviderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void RemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new MetadataDetailsProviderCollection
|
||||
var list = new List<IMetadataDetailsProvider>
|
||||
{
|
||||
new FooMetadataDetailsProvider(),
|
||||
new BarMetadataDetailsProvider(),
|
||||
|
|
@ -20,10 +20,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType(typeof(FooMetadataDetailsProvider));
|
||||
list.RemoveType(typeof(FooMetadataDetailsProvider));
|
||||
|
||||
// Assert
|
||||
var provider = Assert.Single(collection);
|
||||
var provider = Assert.Single(list);
|
||||
Assert.IsType<BarMetadataDetailsProvider>(provider);
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
public void GenericRemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new MetadataDetailsProviderCollection
|
||||
var list = new List<IMetadataDetailsProvider>
|
||||
{
|
||||
new FooMetadataDetailsProvider(),
|
||||
new BarMetadataDetailsProvider(),
|
||||
|
|
@ -39,10 +39,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType<FooMetadataDetailsProvider>();
|
||||
list.RemoveType<FooMetadataDetailsProvider>();
|
||||
|
||||
// Assert
|
||||
var provider = Assert.Single(collection);
|
||||
var provider = Assert.Single(list);
|
||||
Assert.IsType<BarMetadataDetailsProvider>(provider);
|
||||
}
|
||||
|
||||
|
|
@ -2,17 +2,18 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
public class ModelBinderProviderCollectionTests
|
||||
public class ModelBinderProviderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void RemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ModelBinderProviderCollection
|
||||
var list = new List<IModelBinderProvider>
|
||||
{
|
||||
new FooModelBinderProvider(),
|
||||
new BarModelBinderProvider(),
|
||||
|
|
@ -20,10 +21,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType(typeof(FooModelBinderProvider));
|
||||
list.RemoveType(typeof(FooModelBinderProvider));
|
||||
|
||||
// Assert
|
||||
var provider = Assert.Single(collection);
|
||||
var provider = Assert.Single(list);
|
||||
Assert.IsType<BarModelBinderProvider>(provider);
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
public void GenericRemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ModelBinderProviderCollection
|
||||
var list = new List<IModelBinderProvider>
|
||||
{
|
||||
new FooModelBinderProvider(),
|
||||
new BarModelBinderProvider(),
|
||||
|
|
@ -39,10 +40,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType<FooModelBinderProvider>();
|
||||
list.RemoveType<FooModelBinderProvider>();
|
||||
|
||||
// Assert
|
||||
var provider = Assert.Single(collection);
|
||||
var provider = Assert.Single(list);
|
||||
Assert.IsType<BarModelBinderProvider>(provider);
|
||||
}
|
||||
|
||||
|
|
@ -2,17 +2,18 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
||||
{
|
||||
public class ModelValidatorProviderCollectionTests
|
||||
public class ModelValidatorProviderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void RemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ModelValidatorProviderCollection
|
||||
var list = new List<IModelValidatorProvider>
|
||||
{
|
||||
new FooModelValidatorProvider(),
|
||||
new BarModelValidatorProvider(),
|
||||
|
|
@ -20,10 +21,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType(typeof(FooModelValidatorProvider));
|
||||
list.RemoveType(typeof(FooModelValidatorProvider));
|
||||
|
||||
// Assert
|
||||
var provider = Assert.Single(collection);
|
||||
var provider = Assert.Single(list);
|
||||
Assert.IsType<BarModelValidatorProvider>(provider);
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
public void GenericRemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ModelValidatorProviderCollection
|
||||
var list = new List<IModelValidatorProvider>
|
||||
{
|
||||
new FooModelValidatorProvider(),
|
||||
new BarModelValidatorProvider(),
|
||||
|
|
@ -39,10 +40,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType<FooModelValidatorProvider>();
|
||||
list.RemoveType<FooModelValidatorProvider>();
|
||||
|
||||
// Assert
|
||||
var provider = Assert.Single(collection);
|
||||
var provider = Assert.Single(list);
|
||||
Assert.IsType<BarModelValidatorProvider>(provider);
|
||||
}
|
||||
|
||||
|
|
@ -2,18 +2,19 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
public class ValueProviderFactoryCollectionTests
|
||||
public class ValueProviderFactoryExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void RemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ValueProviderFactoryCollection
|
||||
var list = new List<IValueProviderFactory>
|
||||
{
|
||||
new FooValueProviderFactory(),
|
||||
new BarValueProviderFactory(),
|
||||
|
|
@ -21,10 +22,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType(typeof(FooValueProviderFactory));
|
||||
list.RemoveType(typeof(FooValueProviderFactory));
|
||||
|
||||
// Assert
|
||||
var factory = Assert.Single(collection);
|
||||
var factory = Assert.Single(list);
|
||||
Assert.IsType<BarValueProviderFactory>(factory);
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
public void GenericRemoveType_RemovesAllOfType()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ValueProviderFactoryCollection
|
||||
var list = new List<IValueProviderFactory>
|
||||
{
|
||||
new FooValueProviderFactory(),
|
||||
new BarValueProviderFactory(),
|
||||
|
|
@ -40,10 +41,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
};
|
||||
|
||||
// Act
|
||||
collection.RemoveType<FooValueProviderFactory>();
|
||||
list.RemoveType<FooValueProviderFactory>();
|
||||
|
||||
// Assert
|
||||
var factory = Assert.Single(collection);
|
||||
var factory = Assert.Single(list);
|
||||
Assert.IsType<BarValueProviderFactory>(factory);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue