Small Refactorings
Use nameof Replace with single call to SingleOrDefault Replace with single call to FirstOrDefault Simplify conditionals
This commit is contained in:
parent
80b6996701
commit
5b0b0b95a7
|
|
@ -183,7 +183,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Equals(BindingSource other)
|
public bool Equals(BindingSource other)
|
||||||
{
|
{
|
||||||
return other == null ? false : string.Equals(other.Id, Id, StringComparison.Ordinal);
|
return string.Equals(other?.Id, Id, StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
var other = obj as ValueProviderResult?;
|
var other = obj as ValueProviderResult?;
|
||||||
return other.HasValue ? Equals(other.Value) : false;
|
return other.HasValue && Equals(other.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
||||||
|
|
@ -220,8 +220,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
ActionDescriptor action)
|
ActionDescriptor action)
|
||||||
{
|
{
|
||||||
var constraint = action.RouteConstraints
|
var constraint = action.RouteConstraints
|
||||||
.Where(c => c.RouteKey == TreeRouter.RouteGroupKey)
|
.FirstOrDefault(c => c.RouteKey == TreeRouter.RouteGroupKey);
|
||||||
.FirstOrDefault();
|
|
||||||
if (constraint == null ||
|
if (constraint == null ||
|
||||||
constraint.KeyHandling != RouteKeyHandling.RequireKey ||
|
constraint.KeyHandling != RouteKeyHandling.RequireKey ||
|
||||||
constraint.RouteValue == null)
|
constraint.RouteValue == null)
|
||||||
|
|
|
||||||
|
|
@ -592,8 +592,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var routeTemplateProvider =
|
var routeTemplateProvider =
|
||||||
attributes
|
attributes
|
||||||
.OfType<IRouteTemplateProvider>()
|
.OfType<IRouteTemplateProvider>()
|
||||||
.Where(a => !IsSilentRouteAttribute(a))
|
.SingleOrDefault(a => !IsSilentRouteAttribute(a));
|
||||||
.SingleOrDefault();
|
|
||||||
|
|
||||||
if (routeTemplateProvider != null)
|
if (routeTemplateProvider != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(context));
|
throw new ArgumentNullException(nameof(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = context.ActionContext.HttpContext.Request;
|
var request = context.ActionContext.HttpContext.Request;
|
||||||
if (request.HasFormContentType)
|
if (request.HasFormContentType)
|
||||||
{
|
{
|
||||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
{
|
{
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
message: Resources.FormatJQueryFormValueProviderFactory_MissingClosingBracket(key),
|
message: Resources.FormatJQueryFormValueProviderFactory_MissingClosingBracket(key),
|
||||||
paramName: "key");
|
paramName: nameof(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexClose == indexOpen + 1)
|
if (indexClose == indexOpen + 1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue