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 />
|
||||
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 />
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as ValueProviderResult?;
|
||||
return other.HasValue ? Equals(other.Value) : false;
|
||||
return other.HasValue && Equals(other.Value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -220,8 +220,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
ActionDescriptor action)
|
||||
{
|
||||
var constraint = action.RouteConstraints
|
||||
.Where(c => c.RouteKey == TreeRouter.RouteGroupKey)
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefault(c => c.RouteKey == TreeRouter.RouteGroupKey);
|
||||
if (constraint == null ||
|
||||
constraint.KeyHandling != RouteKeyHandling.RequireKey ||
|
||||
constraint.RouteValue == null)
|
||||
|
|
|
|||
|
|
@ -592,8 +592,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
var routeTemplateProvider =
|
||||
attributes
|
||||
.OfType<IRouteTemplateProvider>()
|
||||
.Where(a => !IsSilentRouteAttribute(a))
|
||||
.SingleOrDefault();
|
||||
.SingleOrDefault(a => !IsSilentRouteAttribute(a));
|
||||
|
||||
if (routeTemplateProvider != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
|
||||
var request = context.ActionContext.HttpContext.Request;
|
||||
if (request.HasFormContentType)
|
||||
{
|
||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
{
|
||||
throw new ArgumentException(
|
||||
message: Resources.FormatJQueryFormValueProviderFactory_MissingClosingBracket(key),
|
||||
paramName: "key");
|
||||
paramName: nameof(key));
|
||||
}
|
||||
|
||||
if (indexClose == indexOpen + 1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue