Adding support for .NET 8.0 LTS, renaming private fields to start with underscore
This commit is contained in:
@@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public class InvariantFloatingPointModelBinder : IModelBinder
|
||||
{
|
||||
private readonly NumberStyles supportedNumberStyles;
|
||||
private readonly ILogger logger;
|
||||
private readonly CultureInfo cultureInfo;
|
||||
private readonly NumberStyles _supportedNumberStyles;
|
||||
private readonly ILogger _logger;
|
||||
private readonly CultureInfo _cultureInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="InvariantFloatingPointModelBinder"/>.
|
||||
@@ -24,10 +24,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
|
||||
public InvariantFloatingPointModelBinder(NumberStyles supportedStyles, CultureInfo cultureInfo, ILoggerFactory loggerFactory)
|
||||
{
|
||||
this.cultureInfo = cultureInfo ?? throw new ArgumentNullException(nameof(cultureInfo));
|
||||
_cultureInfo = cultureInfo ?? throw new ArgumentNullException(nameof(cultureInfo));
|
||||
|
||||
supportedNumberStyles = supportedStyles;
|
||||
logger = loggerFactory?.CreateLogger<InvariantFloatingPointModelBinder>();
|
||||
_supportedNumberStyles = supportedStyles;
|
||||
_logger = loggerFactory?.CreateLogger<InvariantFloatingPointModelBinder>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -36,15 +36,15 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
if (bindingContext == null)
|
||||
throw new ArgumentNullException(nameof(bindingContext));
|
||||
|
||||
logger?.AttemptingToBindModel(bindingContext);
|
||||
_logger?.AttemptingToBindModel(bindingContext);
|
||||
string modelName = bindingContext.ModelName;
|
||||
var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
|
||||
if (valueProviderResult == ValueProviderResult.None)
|
||||
{
|
||||
logger?.FoundNoValueInRequest(bindingContext);
|
||||
_logger?.FoundNoValueInRequest(bindingContext);
|
||||
|
||||
// no entry
|
||||
logger?.DoneAttemptingToBindModel(bindingContext);
|
||||
_logger?.DoneAttemptingToBindModel(bindingContext);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
try
|
||||
{
|
||||
string value = valueProviderResult.FirstValue;
|
||||
var culture = cultureInfo ?? valueProviderResult.Culture;
|
||||
var culture = _cultureInfo ?? valueProviderResult.Culture;
|
||||
|
||||
object model;
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
@@ -66,15 +66,15 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
model = float.Parse(value, supportedNumberStyles, culture);
|
||||
model = float.Parse(value, _supportedNumberStyles, culture);
|
||||
}
|
||||
else if (type == typeof(double))
|
||||
{
|
||||
model = double.Parse(value, supportedNumberStyles, culture);
|
||||
model = double.Parse(value, _supportedNumberStyles, culture);
|
||||
}
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
model = decimal.Parse(value, supportedNumberStyles, culture);
|
||||
model = decimal.Parse(value, _supportedNumberStyles, culture);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
// Conversion failed.
|
||||
}
|
||||
|
||||
logger?.DoneAttemptingToBindModel(bindingContext);
|
||||
_logger?.DoneAttemptingToBindModel(bindingContext);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user