Use C# 7 features
This commit is contained in:
parent
1c4b0fcdf3
commit
c27b07ef3f
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.ActionConstraints
|
|||
/// <summary>
|
||||
/// The <see cref="IActionConstraintMetadata"/> instance.
|
||||
/// </summary>
|
||||
public IActionConstraintMetadata Metadata { get; private set; }
|
||||
public IActionConstraintMetadata Metadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not <see cref="Constraint"/> can be reused across requests.
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ namespace Microsoft.AspNetCore.Mvc.ActionConstraints
|
|||
/// <summary>
|
||||
/// The <see cref="ActionDescriptor"/> for which constraints are being created.
|
||||
/// </summary>
|
||||
public ActionDescriptor Action { get; private set; }
|
||||
public ActionDescriptor Action { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of <see cref="ActionConstraintItem"/> objects.
|
||||
/// </summary>
|
||||
public IList<ActionConstraintItem> Results { get; private set; }
|
||||
public IList<ActionConstraintItem> Results { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -31,11 +31,11 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
/// <summary>
|
||||
/// The list of actions.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ActionDescriptor> Actions { get; private set; }
|
||||
public IReadOnlyList<ActionDescriptor> Actions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of resulting <see cref="ApiDescription"/>.
|
||||
/// </summary>
|
||||
public IList<ApiDescription> Results { get; private set; }
|
||||
public IList<ApiDescription> Results { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters
|
|||
/// <summary>
|
||||
/// The <see cref="IFilterMetadata"/> instance.
|
||||
/// </summary>
|
||||
public IFilterMetadata Filter { get; private set; }
|
||||
public IFilterMetadata Filter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The filter order.
|
||||
|
|
@ -64,6 +64,6 @@ namespace Microsoft.AspNetCore.Mvc.Filters
|
|||
/// <summary>
|
||||
/// The filter scope.
|
||||
/// </summary>
|
||||
public int Scope { get; private set; }
|
||||
public int Scope { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,13 +125,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
_providers = providers;
|
||||
}
|
||||
|
||||
public Func<ModelMetadata, bool> PropertyFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return CreatePropertyFilter();
|
||||
}
|
||||
}
|
||||
public Func<ModelMetadata, bool> PropertyFilter => CreatePropertyFilter();
|
||||
|
||||
private Func<ModelMetadata, bool> CreatePropertyFilter()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// </summary>
|
||||
public struct EnumGroupAndName
|
||||
{
|
||||
private Func<string> _name;
|
||||
private readonly Func<string> _name;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnumGroupAndName"/> structure. This constructor should
|
||||
|
|
@ -65,12 +65,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _name();
|
||||
}
|
||||
}
|
||||
public string Name => _name();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
ErrorMessage = errorMessage ?? string.Empty;
|
||||
}
|
||||
|
||||
public Exception Exception { get; private set; }
|
||||
public Exception Exception { get; }
|
||||
|
||||
public string ErrorMessage { get; private set; }
|
||||
public string ErrorMessage { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// Gets the container type of this metadata if it represents a property, otherwise <c>null</c>.
|
||||
/// </summary>
|
||||
public Type ContainerType { get { return Identity.ContainerType; } }
|
||||
public Type ContainerType => Identity.ContainerType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata of the container type that the current instance is part of.
|
||||
|
|
@ -56,23 +56,17 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// Gets a value indicating the kind of metadata element represented by the current instance.
|
||||
/// </summary>
|
||||
public ModelMetadataKind MetadataKind { get { return Identity.MetadataKind; } }
|
||||
public ModelMetadataKind MetadataKind => Identity.MetadataKind;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the model type represented by the current instance.
|
||||
/// </summary>
|
||||
public Type ModelType { get { return Identity.ModelType; } }
|
||||
public Type ModelType => Identity.ModelType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property name represented by the current instance.
|
||||
/// </summary>
|
||||
public string PropertyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Identity.Name;
|
||||
}
|
||||
}
|
||||
public string PropertyName => Identity.Name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key for the current instance.
|
||||
|
|
|
|||
|
|
@ -112,10 +112,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// Returns <c>true</c> if a <see cref="TooManyModelErrorsException"/> has been recorded;
|
||||
/// otherwise <c>false</c>.
|
||||
/// </remarks>
|
||||
public bool HasReachedMaxErrors
|
||||
{
|
||||
get { return ErrorCount >= MaxAllowedErrors; }
|
||||
}
|
||||
public bool HasReachedMaxErrors => ErrorCount >= MaxAllowedErrors;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of errors added to this instance of <see cref="ModelStateDictionary"/> via
|
||||
|
|
|
|||
|
|
@ -33,13 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
/// <remarks>
|
||||
/// This property provides convenience access to <see cref="ModelMetadata.ValidatorMetadata"/>.
|
||||
/// </remarks>
|
||||
public IReadOnlyList<object> ValidatorMetadata
|
||||
{
|
||||
get
|
||||
{
|
||||
return ModelMetadata.ValidatorMetadata;
|
||||
}
|
||||
}
|
||||
public IReadOnlyList<object> ValidatorMetadata => ModelMetadata.ValidatorMetadata;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="ClientValidatorItem"/> instances. <see cref="IClientModelValidatorProvider"/>
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
Message = message ?? string.Empty;
|
||||
}
|
||||
|
||||
public string MemberName { get; private set; }
|
||||
public string MemberName { get; }
|
||||
|
||||
public string Message { get; private set; }
|
||||
public string Message { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,13 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
/// <remarks>
|
||||
/// This property provides convenience access to <see cref="ModelMetadata.ValidatorMetadata"/>.
|
||||
/// </remarks>
|
||||
public IReadOnlyList<object> ValidatorMetadata
|
||||
{
|
||||
get
|
||||
{
|
||||
return ModelMetadata.ValidatorMetadata;
|
||||
}
|
||||
}
|
||||
public IReadOnlyList<object> ValidatorMetadata => ModelMetadata.ValidatorMetadata;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="ValidatorItem"/> instances. <see cref="IModelValidatorProvider"/> instances
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
/// <summary>
|
||||
/// Used for tracking validation state to customize validation behavior for a model object.
|
||||
/// </summary>
|
||||
public class ValidationStateDictionary :
|
||||
IDictionary<object, ValidationStateEntry>,
|
||||
public class ValidationStateDictionary :
|
||||
IDictionary<object, ValidationStateEntry>,
|
||||
IReadOnlyDictionary<object, ValidationStateEntry>
|
||||
{
|
||||
private readonly Dictionary<object, ValidationStateEntry> _inner;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ValidationStateDictionary"/>.
|
||||
/// </summary>
|
||||
|
|
@ -30,8 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
{
|
||||
get
|
||||
{
|
||||
ValidationStateEntry entry;
|
||||
TryGetValue(key, out entry);
|
||||
TryGetValue(key, out var entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
@ -42,58 +41,24 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _inner.Count;
|
||||
}
|
||||
}
|
||||
public int Count => _inner.Count;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IDictionary<object, ValidationStateEntry>)_inner).IsReadOnly;
|
||||
}
|
||||
}
|
||||
public bool IsReadOnly => ((IDictionary<object, ValidationStateEntry>)_inner).IsReadOnly;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ICollection<object> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IDictionary<object, ValidationStateEntry>)_inner).Keys;
|
||||
}
|
||||
}
|
||||
public ICollection<object> Keys => ((IDictionary<object, ValidationStateEntry>)_inner).Keys;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ICollection<ValidationStateEntry> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IDictionary<object, ValidationStateEntry>)_inner).Values;
|
||||
}
|
||||
}
|
||||
public ICollection<ValidationStateEntry> Values => ((IDictionary<object, ValidationStateEntry>)_inner).Values;
|
||||
|
||||
/// <inheritdoc />
|
||||
IEnumerable<object> IReadOnlyDictionary<object, ValidationStateEntry>.Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IReadOnlyDictionary<object, ValidationStateEntry>)_inner).Keys;
|
||||
}
|
||||
}
|
||||
IEnumerable<object> IReadOnlyDictionary<object, ValidationStateEntry>.Keys =>
|
||||
((IReadOnlyDictionary<object, ValidationStateEntry>)_inner).Keys;
|
||||
|
||||
/// <inheritdoc />
|
||||
IEnumerable<ValidationStateEntry> IReadOnlyDictionary<object, ValidationStateEntry>.Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IReadOnlyDictionary<object, ValidationStateEntry>)_inner).Values;
|
||||
}
|
||||
}
|
||||
IEnumerable<ValidationStateEntry> IReadOnlyDictionary<object, ValidationStateEntry>.Values =>
|
||||
((IReadOnlyDictionary<object, ValidationStateEntry>)_inner).Values;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Add(KeyValuePair<object, ValidationStateEntry> item)
|
||||
|
|
@ -160,7 +125,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
{
|
||||
return ((IDictionary<object, ValidationStateEntry>)_inner).GetEnumerator();
|
||||
}
|
||||
|
||||
|
||||
private class ReferenceEqualityComparer : IEqualityComparer<object>
|
||||
{
|
||||
private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null;
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// Gets or sets the <see cref="CultureInfo"/> associated with the values.
|
||||
/// </summary>
|
||||
public CultureInfo Culture { get; private set; }
|
||||
public CultureInfo Culture { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the values.
|
||||
/// </summary>
|
||||
public StringValues Values { get; private set; }
|
||||
public StringValues Values { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first value based on the order values were provided in the request. Use <see cref="FirstValue"/>
|
||||
|
|
@ -84,13 +84,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// Gets the number of submitted values.
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return Values.Count;
|
||||
}
|
||||
}
|
||||
public int Length => Values.Count;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
/// <summary>
|
||||
/// The group name.
|
||||
/// </summary>
|
||||
public string GroupName { get; private set; }
|
||||
public string GroupName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of <see cref="ApiDescription"/> items for this group.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ApiDescription> Items { get; private set; }
|
||||
public IReadOnlyList<ApiDescription> Items { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -30,11 +30,11 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
/// <summary>
|
||||
/// Returns the list of <see cref="IReadOnlyList{ApiDescriptionGroup}"/>.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ApiDescriptionGroup> Items { get; private set; }
|
||||
public IReadOnlyList<ApiDescriptionGroup> Items { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the unique version of the current items.
|
||||
/// </summary>
|
||||
public int Version { get; private set; }
|
||||
public int Version { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -48,10 +48,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order
|
||||
{
|
||||
get { return -1000; }
|
||||
}
|
||||
public int Order => -1000;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnProvidersExecuting(ApiDescriptionProviderContext context)
|
||||
|
|
@ -261,8 +258,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
|
||||
private RouteTemplate ParseTemplate(ControllerActionDescriptor action)
|
||||
{
|
||||
if (action.AttributeRouteInfo != null &&
|
||||
action.AttributeRouteInfo.Template != null)
|
||||
if (action.AttributeRouteInfo?.Template != null)
|
||||
{
|
||||
return TemplateParser.Parse(action.AttributeRouteInfo.Template);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class AcceptVerbsAttribute : Attribute, IActionHttpMethodProvider, IRouteTemplateProvider
|
||||
{
|
||||
private readonly IEnumerable<string> _httpMethods;
|
||||
private int? _order;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -36,19 +35,13 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <param name="methods">The HTTP methods the action supports.</param>
|
||||
public AcceptVerbsAttribute(params string[] methods)
|
||||
{
|
||||
_httpMethods = methods.Select(method => method.ToUpperInvariant());
|
||||
HttpMethods = methods.Select(method => method.ToUpperInvariant());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP methods the action supports.
|
||||
/// </summary>
|
||||
public IEnumerable<string> HttpMethods
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpMethods;
|
||||
}
|
||||
}
|
||||
public IEnumerable<string> HttpMethods { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The route template. May be null.
|
||||
|
|
@ -56,10 +49,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public string Route { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IRouteTemplateProvider.Template
|
||||
{
|
||||
get { return Route; }
|
||||
}
|
||||
string IRouteTemplateProvider.Template => Route;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the route order. The order determines the order of route execution. Routes with a lower
|
||||
|
|
@ -74,13 +64,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
int? IRouteTemplateProvider.Order
|
||||
{
|
||||
get
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
}
|
||||
int? IRouteTemplateProvider.Order => _order;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class AcceptedResult : ObjectResult
|
||||
{
|
||||
private string _location;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AcceptedResult"/> class with the values
|
||||
/// provided.
|
||||
|
|
@ -67,17 +65,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets or sets the location at which the status of the requested content can be monitored.
|
||||
/// </summary>
|
||||
public string Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
set
|
||||
{
|
||||
_location = value;
|
||||
}
|
||||
}
|
||||
public string Location { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnFormatting(ActionContext context)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets the name of the action.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
public string Name { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -31,9 +31,9 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
|||
/// </remarks>
|
||||
public ApiExplorerModel ApiExplorer { get; set; }
|
||||
|
||||
public IList<ControllerModel> Controllers { get; private set; }
|
||||
public IList<ControllerModel> Controllers { get; }
|
||||
|
||||
public IList<IFilterMetadata> Filters { get; private set; }
|
||||
public IList<IFilterMetadata> Filters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a set of properties associated with all actions.
|
||||
|
|
|
|||
|
|
@ -64,14 +64,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
|||
/// </summary>
|
||||
public bool SuppressPathMatching { get; set; }
|
||||
|
||||
public bool IsAbsoluteTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return Template != null &&
|
||||
IsOverridePattern(Template);
|
||||
}
|
||||
}
|
||||
public bool IsAbsoluteTemplate => Template != null && IsOverridePattern(Template);
|
||||
|
||||
/// <summary>
|
||||
/// Combines two <see cref="AttributeRouteModel"/> instances and returns
|
||||
|
|
@ -368,8 +361,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
|||
.Replace("[[", "[")
|
||||
.Replace("]]", "]");
|
||||
|
||||
string value;
|
||||
if (!values.TryGetValue(token, out value))
|
||||
if (!values.TryGetValue(token, out var value))
|
||||
{
|
||||
// Value not found
|
||||
var message = Resources.FormatAttributeRoute_TokenReplacement_ReplacementValueNotFound(
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
|||
|
||||
string ICommonModel.Name => ParameterName;
|
||||
|
||||
public ParameterInfo ParameterInfo { get; private set; }
|
||||
public ParameterInfo ParameterInfo { get; }
|
||||
|
||||
public string ParameterName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Mvc.Authorization
|
|||
/// If<c>null</c>, the policy will be constructed using
|
||||
/// <see cref="AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider, IEnumerable{IAuthorizeData})"/>.
|
||||
/// </remarks>
|
||||
public AuthorizationPolicy Policy { get; private set; }
|
||||
public AuthorizationPolicy Policy { get; }
|
||||
|
||||
bool IFilterFactory.IsReusable => true;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,13 +47,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Represents the model name used during model binding.
|
||||
/// </summary>
|
||||
string IModelNameProvider.Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Prefix;
|
||||
}
|
||||
}
|
||||
string IModelNameProvider.Name => Prefix;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Func<ModelMetadata, bool> PropertyFilter
|
||||
|
|
|
|||
|
|
@ -35,57 +35,27 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets the <see cref="Http.HttpContext"/> for the executing action.
|
||||
/// </summary>
|
||||
public HttpContext HttpContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return ControllerContext.HttpContext;
|
||||
}
|
||||
}
|
||||
public HttpContext HttpContext => ControllerContext.HttpContext;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="HttpRequest"/> for the executing action.
|
||||
/// </summary>
|
||||
public HttpRequest Request
|
||||
{
|
||||
get
|
||||
{
|
||||
return HttpContext?.Request;
|
||||
}
|
||||
}
|
||||
public HttpRequest Request => HttpContext?.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="HttpResponse"/> for the executing action.
|
||||
/// </summary>
|
||||
public HttpResponse Response
|
||||
{
|
||||
get
|
||||
{
|
||||
return HttpContext?.Response;
|
||||
}
|
||||
}
|
||||
public HttpResponse Response => HttpContext?.Response;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="AspNetCore.Routing.RouteData"/> for the executing action.
|
||||
/// </summary>
|
||||
public RouteData RouteData
|
||||
{
|
||||
get
|
||||
{
|
||||
return ControllerContext.RouteData;
|
||||
}
|
||||
}
|
||||
public RouteData RouteData => ControllerContext.RouteData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ModelStateDictionary"/> that contains the state of the model and of model-binding validation.
|
||||
/// </summary>
|
||||
public ModelStateDictionary ModelState
|
||||
{
|
||||
get
|
||||
{
|
||||
return ControllerContext?.ModelState;
|
||||
}
|
||||
}
|
||||
public ModelStateDictionary ModelState => ControllerContext?.ModelState;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Mvc.ControllerContext"/>.
|
||||
|
|
@ -222,13 +192,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets the <see cref="ClaimsPrincipal"/> for user associated with the executing action.
|
||||
/// </summary>
|
||||
public ClaimsPrincipal User
|
||||
{
|
||||
get
|
||||
{
|
||||
return HttpContext?.User;
|
||||
}
|
||||
}
|
||||
public ClaimsPrincipal User => HttpContext?.User;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="StatusCodeResult"/> object by specifying a <paramref name="statusCode"/>.
|
||||
|
|
|
|||
|
|
@ -48,13 +48,7 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
|
|||
/// <summary>
|
||||
/// The <see cref="IControllerActivator"/> used to create a controller.
|
||||
/// </summary>
|
||||
protected IControllerActivator ControllerActivator
|
||||
{
|
||||
get
|
||||
{
|
||||
return _controllerActivator;
|
||||
}
|
||||
}
|
||||
protected IControllerActivator ControllerActivator => _controllerActivator;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual object CreateController(ControllerContext context)
|
||||
|
|
|
|||
|
|
@ -63,10 +63,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public string Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
get => _location;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
|
||||
private class ParameterApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
private IParameterModelConvention _parameterModelConvention;
|
||||
private readonly IParameterModelConvention _parameterModelConvention;
|
||||
|
||||
public ParameterApplicationModelConvention(IParameterModelConvention parameterModelConvention)
|
||||
{
|
||||
|
|
@ -121,7 +121,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
|
||||
private class ActionApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
private IActionModelConvention _actionModelConvention;
|
||||
private readonly IActionModelConvention _actionModelConvention;
|
||||
|
||||
public ActionApplicationModelConvention(IActionModelConvention actionModelConvention)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
|
||||
private class ControllerApplicationModelConvention : IApplicationModelConvention
|
||||
{
|
||||
private IControllerModelConvention _controllerModelConvention;
|
||||
private readonly IControllerModelConvention _controllerModelConvention;
|
||||
|
||||
public ControllerApplicationModelConvention(IControllerModelConvention controllerConvention)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,10 +56,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public byte[] FileContents
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileContents;
|
||||
}
|
||||
get => _fileContents;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public Stream FileStream
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileStream;
|
||||
}
|
||||
get => _fileStream;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// <inheritdoc />
|
||||
public virtual string GetFormat(ActionContext context)
|
||||
{
|
||||
object obj;
|
||||
if (context.RouteData.Values.TryGetValue("format", out obj))
|
||||
if (context.RouteData.Values.TryGetValue("format", out var obj))
|
||||
{
|
||||
// null and string.Empty are equivalent for route values.
|
||||
var routeValue = obj?.ToString();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
{
|
||||
private static readonly StringSegment QualityParameter = new StringSegment("q");
|
||||
|
||||
private MediaTypeParameterParser _parameterParser;
|
||||
private readonly MediaTypeParameterParser _parameterParser;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a <see cref="MediaType"/> instance.
|
||||
|
|
@ -70,8 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
|
||||
_parameterParser = default(MediaTypeParameterParser);
|
||||
|
||||
StringSegment type;
|
||||
var typeLength = GetTypeLength(mediaType, offset, out type);
|
||||
var typeLength = GetTypeLength(mediaType, offset, out var type);
|
||||
if (typeLength == 0)
|
||||
{
|
||||
Type = new StringSegment();
|
||||
|
|
@ -85,8 +84,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
Type = type;
|
||||
}
|
||||
|
||||
StringSegment subType;
|
||||
var subTypeLength = GetSubtypeLength(mediaType, offset + typeLength, out subType);
|
||||
var subTypeLength = GetSubtypeLength(mediaType, offset + typeLength, out var subType);
|
||||
if (subTypeLength == 0)
|
||||
{
|
||||
SubType = new StringSegment();
|
||||
|
|
@ -210,7 +208,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// For the media type <c>"application/vnd.example+json"</c>, this property gives the value
|
||||
/// <c>"vnd.example+json"</c>.
|
||||
/// </example>
|
||||
public StringSegment SubType { get; private set; }
|
||||
public StringSegment SubType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subtype of the <see cref="MediaType"/>, excluding any structured syntax suffix.
|
||||
|
|
@ -219,7 +217,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// For the media type <c>"application/vnd.example+json"</c>, this property gives the value
|
||||
/// <c>"vnd.example"</c>.
|
||||
/// </example>
|
||||
public StringSegment SubTypeWithoutSuffix { get; private set; }
|
||||
public StringSegment SubTypeWithoutSuffix { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the structured syntax suffix of the <see cref="MediaType"/> if it has one.
|
||||
|
|
@ -228,7 +226,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// For the media type <c>"application/vnd.example+json"</c>, this property gives the value
|
||||
/// <c>"json"</c>.
|
||||
/// </example>
|
||||
public StringSegment SubTypeSuffix { get; private set; }
|
||||
public StringSegment SubTypeSuffix { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this <see cref="MediaType"/> matches all subtypes.
|
||||
|
|
@ -318,8 +316,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
{
|
||||
var parametersParser = _parameterParser;
|
||||
|
||||
MediaTypeParameter parameter;
|
||||
while (parametersParser.ParseNextParameter(out parameter))
|
||||
while (parametersParser.ParseNextParameter(out var parameter))
|
||||
{
|
||||
if (parameter.HasName(parameterName))
|
||||
{
|
||||
|
|
@ -411,8 +408,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
var parser = parsedMediaType._parameterParser;
|
||||
|
||||
var quality = 1.0d;
|
||||
MediaTypeParameter parameter;
|
||||
while (parser.ParseNextParameter(out parameter))
|
||||
while (parser.ParseNextParameter(out var parameter))
|
||||
{
|
||||
if (parameter.HasName(QualityParameter))
|
||||
{
|
||||
|
|
@ -512,8 +508,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
private bool ContainsAllParameters(MediaTypeParameterParser setParameters)
|
||||
{
|
||||
var parameterFound = true;
|
||||
MediaTypeParameter setParameter;
|
||||
while (setParameters.ParseNextParameter(out setParameter) && parameterFound)
|
||||
while (setParameters.ParseNextParameter(out var setParameter) && parameterFound)
|
||||
{
|
||||
if (setParameter.HasName("q"))
|
||||
{
|
||||
|
|
@ -533,8 +528,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
// We can do this because it's a struct
|
||||
var subSetParameters = _parameterParser;
|
||||
parameterFound = false;
|
||||
MediaTypeParameter subSetParameter;
|
||||
while (subSetParameters.ParseNextParameter(out subSetParameter) && !parameterFound)
|
||||
while (subSetParameters.ParseNextParameter(out var subSetParameter) && !parameterFound)
|
||||
{
|
||||
parameterFound = subSetParameter.Equals(setParameter);
|
||||
}
|
||||
|
|
@ -545,8 +539,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
|
||||
private struct MediaTypeParameterParser
|
||||
{
|
||||
private string _mediaTypeBuffer;
|
||||
private int? _length;
|
||||
private readonly string _mediaTypeBuffer;
|
||||
private readonly int? _length;
|
||||
|
||||
public MediaTypeParameterParser(string mediaTypeBuffer, int offset, int? length)
|
||||
{
|
||||
|
|
@ -589,8 +583,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
return 0;
|
||||
}
|
||||
|
||||
StringSegment name;
|
||||
var nameLength = GetNameLength(input, startIndex, out name);
|
||||
var nameLength = GetNameLength(input, startIndex, out var name);
|
||||
|
||||
var current = startIndex + nameLength;
|
||||
|
||||
|
|
@ -611,8 +604,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
}
|
||||
}
|
||||
|
||||
StringSegment value;
|
||||
var valueLength = GetValueLength(input, current, out value);
|
||||
var valueLength = GetValueLength(input, current, out var value);
|
||||
|
||||
parsedValue = new MediaTypeParameter(name, value);
|
||||
current += valueLength;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public class FromBodyAttribute : Attribute, IBindingSourceMetadata
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public BindingSource BindingSource { get { return BindingSource.Body; } }
|
||||
public BindingSource BindingSource => BindingSource.Body;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public class FromFormAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public BindingSource BindingSource { get { return BindingSource.Form; } }
|
||||
public BindingSource BindingSource => BindingSource.Form;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public class FromHeaderAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public BindingSource BindingSource { get { return BindingSource.Header; } }
|
||||
public BindingSource BindingSource => BindingSource.Header;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public class FromQueryAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public BindingSource BindingSource { get { return BindingSource.Query; } }
|
||||
public BindingSource BindingSource => BindingSource.Query;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
public class FromRouteAttribute : Attribute, IBindingSourceMetadata, IModelNameProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public BindingSource BindingSource { get { return BindingSource.Path; } }
|
||||
public BindingSource BindingSource => BindingSource.Path;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
|||
/// <summary>
|
||||
/// Returns the cached <see cref="IReadOnlyList{ActionDescriptor}"/>.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ActionDescriptor> Items { get; private set; }
|
||||
public IReadOnlyList<ActionDescriptor> Items { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the unique version of the currently cached items.
|
||||
/// </summary>
|
||||
public int Version { get; private set; }
|
||||
public int Version { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -37,8 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
{
|
||||
var startCharIndex = charIndex;
|
||||
|
||||
MediaTypeSegmentWithQuality output;
|
||||
if (TryParseValue(value, ref charIndex, out output))
|
||||
if (TryParseValue(value, ref charIndex, out var output))
|
||||
{
|
||||
// The entry may not contain an actual value, like Accept: application/json, , */*
|
||||
if (output.MediaType.HasValue)
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
{
|
||||
var cache = CurrentCache;
|
||||
|
||||
CacheEntry entry;
|
||||
if (cache.Entries.TryGetValue(action, out entry))
|
||||
if (cache.Entries.TryGetValue(action, out var entry))
|
||||
{
|
||||
return GetActionConstraintsFromEntry(entry, httpContext, action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,13 +376,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public int Version { get; set; }
|
||||
public int Version { get; }
|
||||
|
||||
public string[] RouteKeys { get; set; }
|
||||
public string[] RouteKeys { get; }
|
||||
|
||||
public Dictionary<string[], List<ActionDescriptor>> OrdinalEntries { get; set; }
|
||||
public Dictionary<string[], List<ActionDescriptor>> OrdinalEntries { get; }
|
||||
|
||||
public Dictionary<string[], List<ActionDescriptor>> OrdinalIgnoreCaseEntries { get; set; }
|
||||
public Dictionary<string[], List<ActionDescriptor>> OrdinalIgnoreCaseEntries { get; }
|
||||
}
|
||||
|
||||
private class StringArrayComparer : IEqualityComparer<string[]>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_policyProvider = policyProvider;
|
||||
}
|
||||
|
||||
public int Order { get { return -1000 + 10; } }
|
||||
public int Order => -1000 + 10;
|
||||
|
||||
public void OnProvidersExecuted(ApplicationModelProviderContext context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
public IReadOnlyList<IClientModelValidator> GetValidators(ModelMetadata metadata, IClientModelValidatorProvider validatorProvider)
|
||||
{
|
||||
CacheEntry entry;
|
||||
if (_cacheEntries.TryGetValue(metadata, out entry))
|
||||
if (_cacheEntries.TryGetValue(metadata, out var entry))
|
||||
{
|
||||
return GetValidatorsFromEntry(entry, metadata, validatorProvider);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -474,9 +474,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
string routeName,
|
||||
ControllerActionDescriptor actionDescriptor)
|
||||
{
|
||||
IList<ActionDescriptor> namedActionGroup;
|
||||
|
||||
if (actionsByRouteName.TryGetValue(routeName, out namedActionGroup))
|
||||
if (actionsByRouteName.TryGetValue(routeName, out var namedActionGroup))
|
||||
{
|
||||
namedActionGroup.Add(actionDescriptor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_conventions = optionsAccessor.Value.Conventions;
|
||||
}
|
||||
|
||||
public int Order
|
||||
{
|
||||
get { return -1000; }
|
||||
}
|
||||
public int Order => -1000;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnProvidersExecuting(ActionDescriptorProviderContext context)
|
||||
|
|
@ -98,14 +95,14 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
}
|
||||
|
||||
internal protected IEnumerable<ControllerActionDescriptor> GetDescriptors()
|
||||
protected internal IEnumerable<ControllerActionDescriptor> GetDescriptors()
|
||||
{
|
||||
var applicationModel = BuildModel();
|
||||
ApplicationModelConventions.ApplyConventions(applicationModel, _conventions);
|
||||
return ControllerActionDescriptorBuilder.Build(applicationModel);
|
||||
}
|
||||
|
||||
internal protected ApplicationModel BuildModel()
|
||||
protected internal ApplicationModel BuildModel()
|
||||
{
|
||||
var controllerTypes = GetControllerTypes();
|
||||
var context = new ApplicationModelProviderContext(controllerTypes);
|
||||
|
|
|
|||
|
|
@ -16,13 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_source = source;
|
||||
}
|
||||
|
||||
protected IReadOnlyList<T> Readable
|
||||
{
|
||||
get
|
||||
{
|
||||
return _copy ?? _source;
|
||||
}
|
||||
}
|
||||
protected IReadOnlyList<T> Readable => _copy ?? _source;
|
||||
|
||||
protected List<T> Writable
|
||||
{
|
||||
|
|
@ -39,31 +33,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
public T this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return Readable[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
Writable[index] = value;
|
||||
}
|
||||
get => Readable[index];
|
||||
set => Writable[index] = value;
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return Readable.Count;
|
||||
}
|
||||
}
|
||||
public int Count => Readable.Count;
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
public class DefaultActionConstraintProvider : IActionConstraintProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public int Order
|
||||
{
|
||||
get { return -1000; }
|
||||
}
|
||||
public int Order => -1000;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnProvidersExecuting(ActionConstraintProviderContext context)
|
||||
|
|
|
|||
|
|
@ -26,13 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
return -1000;
|
||||
}
|
||||
}
|
||||
public int Order => -1000;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void OnProvidersExecuting(ApplicationModelProviderContext context)
|
||||
|
|
@ -485,8 +479,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
var createSelectorForSilentRouteProviders = false;
|
||||
foreach (var attribute in attributes)
|
||||
{
|
||||
var routeTemplateProvider = attribute as IRouteTemplateProvider;
|
||||
if (routeTemplateProvider != null)
|
||||
if (attribute is IRouteTemplateProvider routeTemplateProvider)
|
||||
{
|
||||
if (IsSilentRouteAttribute(routeTemplateProvider))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,13 +99,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_providers = providers;
|
||||
}
|
||||
|
||||
public Func<ModelMetadata, bool> PropertyFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return CreatePropertyFilter();
|
||||
}
|
||||
}
|
||||
public Func<ModelMetadata, bool> PropertyFilter => CreatePropertyFilter();
|
||||
|
||||
private Func<ModelMetadata, bool> CreatePropertyFilter()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,21 +108,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_index = -1;
|
||||
}
|
||||
|
||||
public ValidationEntry Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
}
|
||||
public ValidationEntry Current => _entry;
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,21 +56,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_index = -1;
|
||||
}
|
||||
|
||||
public ValidationEntry Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
}
|
||||
public ValidationEntry Current => _entry;
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
{
|
||||
public class DefaultFilterProvider : IFilterProvider
|
||||
{
|
||||
public int Order
|
||||
{
|
||||
get { return -1000; }
|
||||
}
|
||||
public int Order => -1000;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnProvidersExecuting(FilterProviderContext context)
|
||||
|
|
|
|||
|
|
@ -82,21 +82,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_enumerator = enumerator;
|
||||
}
|
||||
|
||||
public ValidationEntry Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
}
|
||||
public ValidationEntry Current => _entry;
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,12 +9,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
{
|
||||
public class FilterDescriptorOrderComparer : IComparer<FilterDescriptor>
|
||||
{
|
||||
private static readonly FilterDescriptorOrderComparer _comparer = new FilterDescriptorOrderComparer();
|
||||
|
||||
public static FilterDescriptorOrderComparer Comparer
|
||||
{
|
||||
get { return _comparer; }
|
||||
}
|
||||
public static FilterDescriptorOrderComparer Comparer { get; } = new FilterDescriptorOrderComparer();
|
||||
|
||||
public int Compare(FilterDescriptor x, FilterDescriptor y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,18 +42,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_httpMethods = new ReadOnlyCollection<string>(methods);
|
||||
}
|
||||
|
||||
public IEnumerable<string> HttpMethods
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpMethods;
|
||||
}
|
||||
}
|
||||
public IEnumerable<string> HttpMethods => _httpMethods;
|
||||
|
||||
public int Order
|
||||
{
|
||||
get { return HttpMethodConstraintOrder; }
|
||||
}
|
||||
public int Order => HttpMethodConstraintOrder;
|
||||
|
||||
public bool Accept(ActionConstraintContext context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,10 +99,9 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
|
||||
var current = startIndex;
|
||||
|
||||
char c;
|
||||
while (current < input.Length)
|
||||
{
|
||||
c = input[current];
|
||||
var c = input[current];
|
||||
|
||||
if ((c == SP) || (c == Tab))
|
||||
{
|
||||
|
|
@ -202,9 +201,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
{
|
||||
// Only check whether we have a quoted char, if we have at least 3 characters left to read (i.e.
|
||||
// quoted char + closing char). Otherwise the closing char may be considered part of the quoted char.
|
||||
var quotedPairLength = 0;
|
||||
if ((current + 2 < input.Length) &&
|
||||
(GetQuotedPairLength(input, current, out quotedPairLength) == HttpParseResult.Parsed))
|
||||
(GetQuotedPairLength(input, current, out var quotedPairLength) == HttpParseResult.Parsed))
|
||||
{
|
||||
// We ignore invalid quoted-pairs. Invalid quoted-pairs may mean that it looked like a quoted pair,
|
||||
// but we actually have a quoted-string: e.g. "\ü" ('\' followed by a char >127 - quoted-pair only
|
||||
|
|
@ -225,9 +223,14 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
return HttpParseResult.InvalidFormat;
|
||||
}
|
||||
|
||||
var nestedLength = 0;
|
||||
var nestedResult = GetExpressionLength(input, current, openChar, closeChar,
|
||||
supportsNesting, ref nestedCount, out nestedLength);
|
||||
var nestedResult = GetExpressionLength(
|
||||
input,
|
||||
current,
|
||||
openChar,
|
||||
closeChar,
|
||||
supportsNesting,
|
||||
ref nestedCount,
|
||||
out var nestedLength);
|
||||
|
||||
switch (nestedResult)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
{
|
||||
public class MvcAttributeRouteHandler : IRouter
|
||||
{
|
||||
private IActionContextAccessor _actionContextAccessor;
|
||||
private IActionInvokerFactory _actionInvokerFactory;
|
||||
private IActionSelector _actionSelector;
|
||||
private ILogger _logger;
|
||||
private readonly IActionContextAccessor _actionContextAccessor;
|
||||
private readonly IActionInvokerFactory _actionInvokerFactory;
|
||||
private readonly IActionSelector _actionSelector;
|
||||
private readonly ILogger _logger;
|
||||
private DiagnosticSource _diagnosticSource;
|
||||
|
||||
public MvcAttributeRouteHandler(
|
||||
|
|
|
|||
|
|
@ -552,13 +552,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
public int Count => 2;
|
||||
|
||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
{
|
||||
public class MvcRouteHandler : IRouter
|
||||
{
|
||||
private IActionContextAccessor _actionContextAccessor;
|
||||
private IActionInvokerFactory _actionInvokerFactory;
|
||||
private IActionSelector _actionSelector;
|
||||
private ILogger _logger;
|
||||
private DiagnosticSource _diagnosticSource;
|
||||
private readonly IActionContextAccessor _actionContextAccessor;
|
||||
private readonly IActionInvokerFactory _actionInvokerFactory;
|
||||
private readonly IActionSelector _actionSelector;
|
||||
private readonly ILogger _logger;
|
||||
private readonly DiagnosticSource _diagnosticSource;
|
||||
|
||||
public MvcRouteHandler(
|
||||
IActionInvokerFactory actionInvokerFactory,
|
||||
|
|
|
|||
|
|
@ -34,35 +34,19 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
/// <summary>
|
||||
/// The inner stream this object delegates to.
|
||||
/// </summary>
|
||||
protected Stream InnerStream
|
||||
{
|
||||
get { return _innerStream; }
|
||||
}
|
||||
protected Stream InnerStream => _innerStream;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return _innerStream.CanRead; }
|
||||
}
|
||||
public override bool CanRead => _innerStream.CanRead;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return _innerStream.CanSeek; }
|
||||
}
|
||||
public override bool CanSeek => _innerStream.CanSeek;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return _innerStream.CanWrite; }
|
||||
}
|
||||
public override bool CanWrite => _innerStream.CanWrite;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Length
|
||||
{
|
||||
get { return _innerStream.Length; }
|
||||
}
|
||||
|
||||
public override long Length => _innerStream.Length;
|
||||
/// <inheritdoc />
|
||||
public override long Position
|
||||
{
|
||||
|
|
@ -78,10 +62,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanTimeout
|
||||
{
|
||||
get { return _innerStream.CanTimeout; }
|
||||
}
|
||||
public override bool CanTimeout => _innerStream.CanTimeout;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int WriteTimeout
|
||||
|
|
|
|||
|
|
@ -9,17 +9,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
{
|
||||
internal class ReferenceEqualityComparer : IEqualityComparer<object>
|
||||
{
|
||||
private static readonly ReferenceEqualityComparer _instance = new ReferenceEqualityComparer();
|
||||
|
||||
private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null;
|
||||
|
||||
public static ReferenceEqualityComparer Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
public static ReferenceEqualityComparer Instance { get; } = new ReferenceEqualityComparer();
|
||||
|
||||
public new bool Equals(object x, object y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -83,21 +83,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
_keyMappingEnumerator = keyMappings.GetEnumerator();
|
||||
}
|
||||
|
||||
public ValidationEntry Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entry;
|
||||
}
|
||||
}
|
||||
public ValidationEntry Current => _entry;
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,10 +71,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
return _localUrl;
|
||||
}
|
||||
get => _localUrl;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
|
|
|||
|
|
@ -181,8 +181,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
bindingContext.ValueProvider
|
||||
};
|
||||
|
||||
object boundValue;
|
||||
|
||||
using (bindingContext.EnterNestedScope(
|
||||
elementMetadata,
|
||||
fieldName: bindingContext.FieldName,
|
||||
|
|
@ -193,7 +191,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
|
||||
if (bindingContext.Result.IsModelSet)
|
||||
{
|
||||
boundValue = bindingContext.Result.Model;
|
||||
var boundValue = bindingContext.Result.Model;
|
||||
boundCollection.Add(ModelBindingHelper.CastOrDefault<TElement>(boundValue));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
ModelBindingContext bindingContext)
|
||||
{
|
||||
var targetInvocationException = exception as TargetInvocationException;
|
||||
if (targetInvocationException != null && targetInvocationException.InnerException != null)
|
||||
if (targetInvocationException?.InnerException != null)
|
||||
{
|
||||
exception = targetInvocationException.InnerException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,37 +41,13 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
|
||||
private class EmptyFormCollection : IFormCollection
|
||||
{
|
||||
public StringValues this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return StringValues.Empty;
|
||||
}
|
||||
}
|
||||
public StringValues this[string key] => StringValues.Empty;
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int Count => 0;
|
||||
|
||||
public IFormFileCollection Files
|
||||
{
|
||||
get
|
||||
{
|
||||
return new EmptyFormFileCollection();
|
||||
}
|
||||
}
|
||||
public IFormFileCollection Files => new EmptyFormFileCollection();
|
||||
|
||||
public ICollection<string> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
public ICollection<string> Keys => new List<string>();
|
||||
|
||||
public bool ContainsKey(string key)
|
||||
{
|
||||
|
|
@ -97,23 +73,11 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
|
||||
private class EmptyFormFileCollection : List<IFormFile>, IFormFileCollection
|
||||
{
|
||||
public IFormFile this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public IFormFile this[string name] => null;
|
||||
|
||||
public IFormFile GetFile(string name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public IFormFile GetFile(string name) => null;
|
||||
|
||||
IReadOnlyList<IFormFile> IFormFileCollection.GetFiles(string name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
IReadOnlyList<IFormFile> IFormFileCollection.GetFiles(string name) => null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// Gets the <see cref="BindingBehavior"/> to apply.
|
||||
/// </summary>
|
||||
public BindingBehavior Behavior { get; private set; }
|
||||
public BindingBehavior Behavior { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,25 +22,13 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <summary>
|
||||
/// The prefix which is used while generating the property filter.
|
||||
/// </summary>
|
||||
public virtual string Prefix
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
public virtual string Prefix => string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Expressions which can be used to generate property filter which can filter model
|
||||
/// properties.
|
||||
/// </summary>
|
||||
public virtual IEnumerable<Expression<Func<TModel, object>>> PropertyIncludeExpressions
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public virtual IEnumerable<Expression<Func<TModel, object>>> PropertyIncludeExpressions => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual Func<ModelMetadata, bool> PropertyFilter
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
public class FormValueProvider : BindingSourceValueProvider, IEnumerableValueProvider
|
||||
{
|
||||
private readonly CultureInfo _culture;
|
||||
private readonly IFormCollection _values;
|
||||
private PrefixContainer _prefixContainer;
|
||||
private IFormCollection _values;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a value provider for <see cref="IFormCollection"/>.
|
||||
|
|
@ -44,13 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
_culture = culture;
|
||||
}
|
||||
|
||||
public CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _culture;
|
||||
}
|
||||
}
|
||||
public CultureInfo Culture => _culture;
|
||||
|
||||
protected PrefixContainer PrefixContainer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -331,8 +331,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Internal
|
|||
}
|
||||
|
||||
var memberExpression = (MemberExpression)expression;
|
||||
var memberInfo = memberExpression.Member as PropertyInfo;
|
||||
if (memberInfo != null)
|
||||
if (memberExpression.Member is PropertyInfo memberInfo)
|
||||
{
|
||||
if (memberExpression.Expression.NodeType != ExpressionType.Parameter)
|
||||
{
|
||||
|
|
@ -531,8 +530,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Internal
|
|||
return false;
|
||||
}
|
||||
|
||||
var collection = model as ICollection<T>;
|
||||
if (collection != null && !collection.IsReadOnly)
|
||||
if (model is ICollection<T> collection && !collection.IsReadOnly)
|
||||
{
|
||||
// Can use the existing collection.
|
||||
return true;
|
||||
|
|
@ -615,8 +613,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Internal
|
|||
}
|
||||
|
||||
// Does collection exist and can it be reused?
|
||||
var collection = model as ICollection<T>;
|
||||
if (collection != null && !collection.IsReadOnly)
|
||||
if (model is ICollection<T> collection && !collection.IsReadOnly)
|
||||
{
|
||||
collection.Clear();
|
||||
|
||||
|
|
@ -739,8 +736,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Internal
|
|||
destinationType = UnwrapNullableType(destinationType);
|
||||
|
||||
// if this is a user-input value but the user didn't type anything, return no value
|
||||
var valueAsString = value as string;
|
||||
if (valueAsString != null && string.IsNullOrWhiteSpace(valueAsString))
|
||||
if (value is string valueAsString && string.IsNullOrWhiteSpace(valueAsString))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
/// </summary>
|
||||
public DefaultModelBindingMessageProvider ModelBindingMessageProvider
|
||||
{
|
||||
get
|
||||
{
|
||||
return _messageProvider;
|
||||
}
|
||||
get => _messageProvider;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
|
|||
|
|
@ -88,22 +88,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
/// <summary>
|
||||
/// Gets the set of attributes for the current instance.
|
||||
/// </summary>
|
||||
public ModelAttributes Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return _details.ModelAttributes;
|
||||
}
|
||||
}
|
||||
public ModelAttributes Attributes => _details.ModelAttributes;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ModelMetadata ContainerMetadata
|
||||
{
|
||||
get
|
||||
{
|
||||
return _details.ContainerMetadata;
|
||||
}
|
||||
}
|
||||
public override ModelMetadata ContainerMetadata => _details.ContainerMetadata;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Metadata.BindingMetadata"/> for the current instance.
|
||||
|
|
@ -188,49 +176,19 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override BindingSource BindingSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return BindingMetadata.BindingSource;
|
||||
}
|
||||
}
|
||||
public override BindingSource BindingSource => BindingMetadata.BindingSource;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string BinderModelName
|
||||
{
|
||||
get
|
||||
{
|
||||
return BindingMetadata.BinderModelName;
|
||||
}
|
||||
}
|
||||
public override string BinderModelName => BindingMetadata.BinderModelName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Type BinderType
|
||||
{
|
||||
get
|
||||
{
|
||||
return BindingMetadata.BinderType;
|
||||
}
|
||||
}
|
||||
public override Type BinderType => BindingMetadata.BinderType;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool ConvertEmptyStringToNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.ConvertEmptyStringToNull;
|
||||
}
|
||||
}
|
||||
public override bool ConvertEmptyStringToNull => DisplayMetadata.ConvertEmptyStringToNull;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string DataTypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.DataTypeName;
|
||||
}
|
||||
}
|
||||
public override string DataTypeName => DisplayMetadata.DataTypeName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Description
|
||||
|
|
@ -247,13 +205,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string DisplayFormatString
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.DisplayFormatString;
|
||||
}
|
||||
}
|
||||
public override string DisplayFormatString => DisplayMetadata.DisplayFormatString;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string DisplayName
|
||||
|
|
@ -270,13 +222,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string EditFormatString
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.EditFormatString;
|
||||
}
|
||||
}
|
||||
public override string EditFormatString => DisplayMetadata.EditFormatString;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ModelMetadata ElementMetadata
|
||||
|
|
@ -294,48 +240,19 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<KeyValuePair<EnumGroupAndName, string>> EnumGroupedDisplayNamesAndValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.EnumGroupedDisplayNamesAndValues;
|
||||
}
|
||||
}
|
||||
=> DisplayMetadata.EnumGroupedDisplayNamesAndValues;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IReadOnlyDictionary<string, string> EnumNamesAndValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.EnumNamesAndValues;
|
||||
}
|
||||
}
|
||||
public override IReadOnlyDictionary<string, string> EnumNamesAndValues => DisplayMetadata.EnumNamesAndValues;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HasNonDefaultEditFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.HasNonDefaultEditFormat;
|
||||
}
|
||||
}
|
||||
public override bool HasNonDefaultEditFormat => DisplayMetadata.HasNonDefaultEditFormat;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HideSurroundingHtml
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.HideSurroundingHtml;
|
||||
}
|
||||
}
|
||||
public override bool HideSurroundingHtml => DisplayMetadata.HideSurroundingHtml;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HtmlEncode
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.HtmlEncode;
|
||||
}
|
||||
}
|
||||
public override bool HtmlEncode => DisplayMetadata.HtmlEncode;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsBindingAllowed
|
||||
|
|
@ -375,22 +292,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnum
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.IsEnum;
|
||||
}
|
||||
}
|
||||
public override bool IsEnum => DisplayMetadata.IsEnum;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsFlagsEnum
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.IsFlagsEnum;
|
||||
}
|
||||
}
|
||||
public override bool IsFlagsEnum => DisplayMetadata.IsFlagsEnum;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsReadOnly
|
||||
|
|
@ -440,31 +345,14 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ModelBindingMessageProvider ModelBindingMessageProvider
|
||||
{
|
||||
get
|
||||
{
|
||||
return BindingMetadata.ModelBindingMessageProvider;
|
||||
}
|
||||
}
|
||||
public override ModelBindingMessageProvider ModelBindingMessageProvider =>
|
||||
BindingMetadata.ModelBindingMessageProvider;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string NullDisplayText
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.NullDisplayText;
|
||||
}
|
||||
}
|
||||
public override string NullDisplayText => DisplayMetadata.NullDisplayText;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.Order;
|
||||
}
|
||||
}
|
||||
public override int Order => DisplayMetadata.Order;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Placeholder
|
||||
|
|
@ -497,58 +385,22 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IPropertyFilterProvider PropertyFilterProvider
|
||||
{
|
||||
get
|
||||
{
|
||||
return BindingMetadata.PropertyFilterProvider;
|
||||
}
|
||||
}
|
||||
public override IPropertyFilterProvider PropertyFilterProvider => BindingMetadata.PropertyFilterProvider;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool ShowForDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.ShowForDisplay;
|
||||
}
|
||||
}
|
||||
public override bool ShowForDisplay => DisplayMetadata.ShowForDisplay;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool ShowForEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.ShowForEdit;
|
||||
}
|
||||
}
|
||||
public override bool ShowForEdit => DisplayMetadata.ShowForEdit;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string SimpleDisplayProperty
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.SimpleDisplayProperty;
|
||||
}
|
||||
}
|
||||
public override string SimpleDisplayProperty => DisplayMetadata.SimpleDisplayProperty;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string TemplateHint
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayMetadata.TemplateHint;
|
||||
}
|
||||
}
|
||||
public override string TemplateHint => DisplayMetadata.TemplateHint;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IPropertyValidationFilter PropertyValidationFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return ValidationMetadata.PropertyValidationFilter;
|
||||
}
|
||||
}
|
||||
public override IPropertyValidationFilter PropertyValidationFilter => ValidationMetadata.PropertyValidationFilter;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool ValidateChildren
|
||||
|
|
@ -590,22 +442,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Func<object, object> PropertyGetter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _details.PropertyGetter;
|
||||
}
|
||||
}
|
||||
public override Func<object, object> PropertyGetter => _details.PropertyGetter;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Action<object, object> PropertySetter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _details.PropertySetter;
|
||||
}
|
||||
}
|
||||
public override Action<object, object> PropertySetter => _details.PropertySetter;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ModelMetadata GetMetadataForType(Type modelType)
|
||||
|
|
|
|||
|
|
@ -251,9 +251,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
|||
Details = details;
|
||||
}
|
||||
|
||||
public ModelMetadata Metadata { get; private set; }
|
||||
public ModelMetadata Metadata { get; }
|
||||
|
||||
public DefaultMetadataDetails Details { get; private set; }
|
||||
public DefaultMetadataDetails Details { get; }
|
||||
}
|
||||
|
||||
private class ModelMetadataIdentityComparer : IEqualityComparer<ModelMetadataIdentity>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
public class QueryStringValueProvider : BindingSourceValueProvider, IEnumerableValueProvider
|
||||
{
|
||||
private readonly CultureInfo _culture;
|
||||
private readonly IQueryCollection _values;
|
||||
private PrefixContainer _prefixContainer;
|
||||
private IQueryCollection _values;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a value provider for <see cref="IQueryCollection"/>.
|
||||
|
|
@ -44,13 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
_culture = culture;
|
||||
}
|
||||
|
||||
public CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _culture;
|
||||
}
|
||||
}
|
||||
public CultureInfo Culture => _culture;
|
||||
|
||||
protected PrefixContainer PrefixContainer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
private readonly ActionContext _actionContext;
|
||||
private readonly ModelStateDictionary _modelState;
|
||||
private readonly ValidationStateDictionary _validationState;
|
||||
private readonly ValidationStack _currentPath;
|
||||
|
||||
private object _container;
|
||||
private string _key;
|
||||
|
|
@ -28,8 +29,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
|
|||
private ModelMetadata _metadata;
|
||||
private IValidationStrategy _strategy;
|
||||
|
||||
private ValidationStack _currentPath;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ValidationVisitor"/>.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public int MaxModelValidationErrors
|
||||
{
|
||||
get { return _maxModelStateErrors; }
|
||||
get => _maxModelStateErrors;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
|
|
|
|||
|
|
@ -54,10 +54,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public string FileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileName;
|
||||
}
|
||||
get => _fileName;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
|
|||
|
|
@ -81,10 +81,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
return _url;
|
||||
}
|
||||
get => _url;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
|
|
|||
|
|
@ -29,14 +29,8 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public int Duration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _duration ?? 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
_duration = value;
|
||||
}
|
||||
get => _duration ?? 0;
|
||||
set => _duration = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -44,14 +38,8 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public ResponseCacheLocation Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return _location ?? ResponseCacheLocation.Any;
|
||||
}
|
||||
set
|
||||
{
|
||||
_location = value;
|
||||
}
|
||||
get => _location ?? ResponseCacheLocation.Any;
|
||||
set => _location = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -62,14 +50,8 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public bool NoStore
|
||||
{
|
||||
get
|
||||
{
|
||||
return _noStore ?? false;
|
||||
}
|
||||
set
|
||||
{
|
||||
_noStore = value;
|
||||
}
|
||||
get => _noStore ?? false;
|
||||
set => _noStore = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Template { get; private set; }
|
||||
public string Template { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the route order. The order determines the order of route execution. Routes with a lower order
|
||||
|
|
@ -44,13 +44,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
int? IRouteTemplateProvider.Order
|
||||
{
|
||||
get
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
}
|
||||
int? IRouteTemplateProvider.Order => _order;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
|||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
public abstract class HttpMethodAttribute : Attribute, IActionHttpMethodProvider, IRouteTemplateProvider
|
||||
{
|
||||
private readonly IEnumerable<string> _httpMethods;
|
||||
private int? _order;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -42,21 +41,15 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
|||
throw new ArgumentNullException(nameof(httpMethods));
|
||||
}
|
||||
|
||||
_httpMethods = httpMethods;
|
||||
HttpMethods = httpMethods;
|
||||
Template = template;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<string> HttpMethods
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpMethods;
|
||||
}
|
||||
}
|
||||
public IEnumerable<string> HttpMethods { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Template { get; private set; }
|
||||
public string Template { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the route order. The order determines the order of route execution. Routes with a lower
|
||||
|
|
@ -71,13 +64,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
int? IRouteTemplateProvider.Order
|
||||
{
|
||||
get
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
}
|
||||
int? IRouteTemplateProvider.Order => _order;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -116,9 +116,9 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
|||
Items = items;
|
||||
}
|
||||
|
||||
public int Version { get; private set; }
|
||||
public int Version { get; }
|
||||
|
||||
public string[] Items { get; private set; }
|
||||
public string[] Items { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// <summary>
|
||||
/// Gets the HTTP status code.
|
||||
/// </summary>
|
||||
public int StatusCode { get; private set; }
|
||||
public int StatusCode { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ExecuteResult(ActionContext context)
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ namespace Microsoft.AspNetCore.Mvc.Cors
|
|||
/// </summary>
|
||||
public class CorsAuthorizationFilter : ICorsAuthorizationFilter
|
||||
{
|
||||
private ICorsService _corsService;
|
||||
private ICorsPolicyProvider _corsPolicyProvider;
|
||||
private readonly ICorsService _corsService;
|
||||
private readonly ICorsPolicyProvider _corsPolicyProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="CorsAuthorizationFilter"/>.
|
||||
|
|
@ -38,16 +38,9 @@ namespace Microsoft.AspNetCore.Mvc.Cors
|
|||
public string PolicyName { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Since clients' preflight requests would not have data to authenticate requests, this
|
||||
// filter must run before any other authorization filters.
|
||||
return int.MinValue + 100;
|
||||
}
|
||||
}
|
||||
|
||||
// Since clients' preflight requests would not have data to authenticate requests, this
|
||||
// filter must run before any other authorization filters.
|
||||
public int Order => int.MinValue + 100;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task OnAuthorizationAsync(Filters.AuthorizationFilterContext context)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal
|
|||
{
|
||||
public class CorsApplicationModelProvider : IApplicationModelProvider
|
||||
{
|
||||
public int Order { get { return -1000 + 10; } }
|
||||
public int Order => -1000 + 10;
|
||||
|
||||
public void OnProvidersExecuted(ApplicationModelProviderContext context)
|
||||
{
|
||||
|
|
@ -28,18 +28,15 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal
|
|||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
IEnableCorsAttribute enableCors;
|
||||
IDisableCorsAttribute disableCors;
|
||||
|
||||
foreach (var controllerModel in context.Result.Controllers)
|
||||
{
|
||||
enableCors = controllerModel.Attributes.OfType<IEnableCorsAttribute>().FirstOrDefault();
|
||||
var enableCors = controllerModel.Attributes.OfType<IEnableCorsAttribute>().FirstOrDefault();
|
||||
if (enableCors != null)
|
||||
{
|
||||
controllerModel.Filters.Add(new CorsAuthorizationFilterFactory(enableCors.PolicyName));
|
||||
}
|
||||
|
||||
disableCors = controllerModel.Attributes.OfType<IDisableCorsAttribute>().FirstOrDefault();
|
||||
var disableCors = controllerModel.Attributes.OfType<IDisableCorsAttribute>().FirstOrDefault();
|
||||
if (disableCors != null)
|
||||
{
|
||||
controllerModel.Filters.Add(new DisableCorsAuthorizationFilter());
|
||||
|
|
|
|||
|
|
@ -24,15 +24,9 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Since clients' preflight requests would not have data to authenticate requests, this
|
||||
// filter must run before any other authorization filters.
|
||||
return int.MinValue + 100;
|
||||
}
|
||||
}
|
||||
// Since clients' preflight requests would not have data to authenticate requests, this
|
||||
// filter must run before any other authorization filters.
|
||||
public int Order => int.MinValue + 100;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsReusable => true;
|
||||
|
|
|
|||
|
|
@ -16,15 +16,9 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal
|
|||
public class DisableCorsAuthorizationFilter : ICorsAuthorizationFilter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Since clients' preflight requests would not have data to authenticate requests, this
|
||||
// filter must run before any other authorization filters.
|
||||
return int.MinValue + 100;
|
||||
}
|
||||
}
|
||||
// Since clients' preflight requests would not have data to authenticate requests, this
|
||||
// filter must run before any other authorization filters.
|
||||
public int Order => int.MinValue + 100;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task OnAuthorizationAsync(AuthorizationFilterContext context)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
|
|||
|
||||
// DisplayName
|
||||
// DisplayAttribute has precendence over DisplayNameAttribute.
|
||||
if (displayAttribute != null && displayAttribute.GetName() != null)
|
||||
if (displayAttribute?.GetName() != null)
|
||||
{
|
||||
if (localizer != null &&
|
||||
!string.IsNullOrEmpty(displayAttribute.Name) &&
|
||||
|
|
|
|||
|
|
@ -99,14 +99,12 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal
|
|||
|
||||
var response = context.HttpContext.Response;
|
||||
|
||||
string resolvedContentType;
|
||||
Encoding resolvedContentTypeEncoding;
|
||||
ResponseContentTypeHelper.ResolveContentTypeAndEncoding(
|
||||
result.ContentType,
|
||||
response.ContentType,
|
||||
DefaultContentType,
|
||||
out resolvedContentType,
|
||||
out resolvedContentTypeEncoding);
|
||||
out var resolvedContentType,
|
||||
out var resolvedContentTypeEncoding);
|
||||
|
||||
response.ContentType = resolvedContentType;
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
jsonReader.CloseInput = false;
|
||||
|
||||
var successful = true;
|
||||
EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs> errorHandler = (sender, eventArgs) =>
|
||||
|
||||
void ErrorHandler(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs eventArgs)
|
||||
{
|
||||
successful = false;
|
||||
|
||||
|
|
@ -180,11 +181,11 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
// Failure to do so can cause the exception to be rethrown at every recursive level and
|
||||
// overflow the stack for x64 CLR processes
|
||||
eventArgs.ErrorContext.Handled = true;
|
||||
};
|
||||
}
|
||||
|
||||
var type = context.ModelType;
|
||||
var jsonSerializer = CreateJsonSerializer();
|
||||
jsonSerializer.Error += errorHandler;
|
||||
jsonSerializer.Error += ErrorHandler;
|
||||
object model;
|
||||
try
|
||||
{
|
||||
|
|
@ -193,7 +194,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
finally
|
||||
{
|
||||
// Clean up the error handler since CreateJsonSerializer() pools instances.
|
||||
jsonSerializer.Error -= errorHandler;
|
||||
jsonSerializer.Error -= ErrorHandler;
|
||||
ReleaseJsonSerializer(jsonSerializer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Json
|
|||
/// <remarks>
|
||||
/// The order -999 ensures that this provider is executed right after the <c>Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiDescriptionProvider</c>.
|
||||
/// </remarks>
|
||||
public int Order
|
||||
{
|
||||
get { return -999; }
|
||||
}
|
||||
public int Order => -999;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnProvidersExecuting(ApiDescriptionProviderContext context)
|
||||
|
|
|
|||
|
|
@ -53,13 +53,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -11,13 +11,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
|
|||
public class SerializableErrorWrapperProvider : IWrapperProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public Type WrappingType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(SerializableErrorWrapper);
|
||||
}
|
||||
}
|
||||
public Type WrappingType => typeof(SerializableErrorWrapper);
|
||||
|
||||
/// <inheritdoc />
|
||||
public object Wrap(object original)
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public class XmlDataContractSerializerInputFormatter : TextInputFormatter
|
||||
{
|
||||
private DataContractSerializerSettings _serializerSettings;
|
||||
private ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
private readonly ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
private readonly XmlDictionaryReaderQuotas _readerQuotas = FormattingUtilities.GetDefaultXmlReaderQuotas();
|
||||
private readonly bool _suppressInputFormatterBuffering;
|
||||
private DataContractSerializerSettings _serializerSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of DataContractSerializerInputFormatter
|
||||
|
|
@ -78,10 +78,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// The quotas include - DefaultMaxDepth, DefaultMaxStringContentLength, DefaultMaxArrayLength,
|
||||
/// DefaultMaxBytesPerRead, DefaultMaxNameTableCharCount
|
||||
/// </summary>
|
||||
public XmlDictionaryReaderQuotas XmlDictionaryReaderQuotas
|
||||
{
|
||||
get { return _readerQuotas; }
|
||||
}
|
||||
public XmlDictionaryReaderQuotas XmlDictionaryReaderQuotas => _readerQuotas;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="DataContractSerializerSettings"/> used to configure the
|
||||
|
|
@ -89,7 +86,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public DataContractSerializerSettings SerializerSettings
|
||||
{
|
||||
get { return _serializerSettings; }
|
||||
get => _serializerSettings;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
@ -137,8 +134,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
// Unwrap only if the original type was wrapped.
|
||||
if (type != context.ModelType)
|
||||
{
|
||||
var unwrappable = deserializedObject as IUnwrappable;
|
||||
if (unwrappable != null)
|
||||
if (deserializedObject is IUnwrappable unwrappable)
|
||||
{
|
||||
deserializedObject = unwrappable.Unwrap(declaredType: context.ModelType);
|
||||
}
|
||||
|
|
@ -234,8 +230,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
object serializer;
|
||||
if (!_serializerCache.TryGetValue(type, out serializer))
|
||||
if (!_serializerCache.TryGetValue(type, out var serializer))
|
||||
{
|
||||
serializer = CreateSerializer(type);
|
||||
if (serializer != null)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public class XmlDataContractSerializerOutputFormatter : TextOutputFormatter
|
||||
{
|
||||
private readonly ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
private DataContractSerializerSettings _serializerSettings;
|
||||
private ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="XmlDataContractSerializerOutputFormatter"/>
|
||||
|
|
@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public DataContractSerializerSettings SerializerSettings
|
||||
{
|
||||
get { return _serializerSettings; }
|
||||
get => _serializerSettings;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
@ -225,8 +225,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// <returns>The <see cref="DataContractSerializer"/> instance.</returns>
|
||||
protected virtual DataContractSerializer GetCachedSerializer(Type type)
|
||||
{
|
||||
object serializer;
|
||||
if (!_serializerCache.TryGetValue(type, out serializer))
|
||||
if (!_serializerCache.TryGetValue(type, out var serializer))
|
||||
{
|
||||
serializer = CreateSerializer(type);
|
||||
if (serializer != null)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public class XmlSerializerInputFormatter : TextInputFormatter
|
||||
{
|
||||
private ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
private readonly ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
private readonly XmlDictionaryReaderQuotas _readerQuotas = FormattingUtilities.GetDefaultXmlReaderQuotas();
|
||||
private readonly bool _suppressInputFormatterBuffering;
|
||||
|
||||
|
|
@ -75,10 +75,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// The quotas include - DefaultMaxDepth, DefaultMaxStringContentLength, DefaultMaxArrayLength,
|
||||
/// DefaultMaxBytesPerRead, DefaultMaxNameTableCharCount
|
||||
/// </summary>
|
||||
public XmlDictionaryReaderQuotas XmlDictionaryReaderQuotas
|
||||
{
|
||||
get { return _readerQuotas; }
|
||||
}
|
||||
public XmlDictionaryReaderQuotas XmlDictionaryReaderQuotas => _readerQuotas;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task<InputFormatterResult> ReadRequestBodyAsync(
|
||||
|
|
@ -119,8 +116,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
// Unwrap only if the original type was wrapped.
|
||||
if (type != context.ModelType)
|
||||
{
|
||||
var unwrappable = deserializedObject as IUnwrappable;
|
||||
if (unwrappable != null)
|
||||
if (deserializedObject is IUnwrappable unwrappable)
|
||||
{
|
||||
deserializedObject = unwrappable.Unwrap(declaredType: context.ModelType);
|
||||
}
|
||||
|
|
@ -210,8 +206,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
object serializer;
|
||||
if (!_serializerCache.TryGetValue(type, out serializer))
|
||||
if (!_serializerCache.TryGetValue(type, out var serializer))
|
||||
{
|
||||
serializer = CreateSerializer(type);
|
||||
if (serializer != null)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public class XmlSerializerOutputFormatter : TextOutputFormatter
|
||||
{
|
||||
private ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
private readonly ConcurrentDictionary<Type, object> _serializerCache = new ConcurrentDictionary<Type, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="XmlSerializerOutputFormatter"/>
|
||||
|
|
@ -203,8 +203,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// <returns>The <see cref="XmlSerializer"/> instance.</returns>
|
||||
protected virtual XmlSerializer GetCachedSerializer(Type type)
|
||||
{
|
||||
object serializer;
|
||||
if (!_serializerCache.TryGetValue(type, out serializer))
|
||||
if (!_serializerCache.TryGetValue(type, out var serializer))
|
||||
{
|
||||
serializer = CreateSerializer(type);
|
||||
if (serializer != null)
|
||||
|
|
|
|||
|
|
@ -36,10 +36,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
/// <summary>
|
||||
/// Gets the asynchronous delegate to invoke when <see cref="WriteTo(TextWriter, HtmlEncoder)"/> is called.
|
||||
/// </summary>
|
||||
public Func<TextWriter, Task> WriteAction
|
||||
{
|
||||
get { return _asyncAction; }
|
||||
}
|
||||
public Func<TextWriter, Task> WriteAction => _asyncAction;
|
||||
|
||||
/// <summary>
|
||||
/// Method invoked to produce content from the <see cref="HelperResult"/>.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
|||
private readonly Action<RoslynCompilationContext> _compilationCallback;
|
||||
private readonly ILogger _logger;
|
||||
private readonly CSharpCompiler _csharpCompiler;
|
||||
private IMemoryCache _cache;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
public RazorViewCompiler(
|
||||
IFileProvider fileProvider,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue