qol: inline variable declaration
This commit is contained in:
@@ -113,8 +113,7 @@ namespace Disco.Services.Devices.Importing
|
||||
if (columnsByType == null)
|
||||
throw new ArgumentNullException(nameof(columnsByType));
|
||||
|
||||
DeviceImportColumn column;
|
||||
if (columnsByType.TryGetValue(FieldType, out column))
|
||||
if (columnsByType.TryGetValue(FieldType, out var column))
|
||||
{
|
||||
return column.Index;
|
||||
}
|
||||
|
||||
@@ -102,8 +102,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
int? value;
|
||||
return TryGetNullableInt(c, out value);
|
||||
return TryGetNullableInt(c, out var value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -112,8 +111,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
int? value;
|
||||
return TryGetNullableInt(c, out value) && value.HasValue;
|
||||
return TryGetNullableInt(c, out var value) && value.HasValue;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,8 +120,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
bool? value;
|
||||
return TryGetNullableBool(c, out value);
|
||||
return TryGetNullableBool(c, out var value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,8 +129,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
DateTime? value;
|
||||
return TryGetNullableDateTime(c, out value);
|
||||
return TryGetNullableDateTime(c, out var value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -153,8 +149,7 @@ namespace Disco.Services.Devices.Importing
|
||||
{
|
||||
content = content.Trim();
|
||||
|
||||
DateTime valueDateTime;
|
||||
if (DateTime.TryParse(content, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out valueDateTime))
|
||||
if (DateTime.TryParse(content, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out var valueDateTime))
|
||||
{
|
||||
value = valueDateTime;
|
||||
return true;
|
||||
@@ -205,8 +200,7 @@ namespace Disco.Services.Devices.Importing
|
||||
}
|
||||
else
|
||||
{
|
||||
int intValue;
|
||||
if (int.TryParse(content, out intValue))
|
||||
if (int.TryParse(content, out var intValue))
|
||||
{
|
||||
value = intValue;
|
||||
return true;
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
parsedValue = new DateTime((parsedValue.Value.Ticks / 10000000L) * 10000000L);
|
||||
}
|
||||
|
||||
string errorMessage;
|
||||
if (parsedValue.HasValue && !CanDecommissionDevice(ExistingDevice, Context, DataReader, out errorMessage))
|
||||
if (parsedValue.HasValue && !CanDecommissionDevice(ExistingDevice, Context, DataReader, out var errorMessage))
|
||||
return Error(errorMessage);
|
||||
|
||||
var decommissionReasonIndex = Context.GetColumnByType(DeviceImportFieldTypes.DeviceDecommissionedReason);
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
}
|
||||
else
|
||||
{
|
||||
DecommissionReasons valueReason;
|
||||
if (!decommissionReasonsMap.Value.TryGetValue(value.Trim(), out valueReason))
|
||||
if (!decommissionReasonsMap.Value.TryGetValue(value.Trim(), out var valueReason))
|
||||
{
|
||||
rawValue = value.Trim();
|
||||
return Error("Cannot parse the value as a Decommission Reason");
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
|
||||
public override bool Parse(DiscoDataContext Database, IDeviceImportCache Cache, IDeviceImportContext Context, string DeviceSerialNumber, Device ExistingDevice, List<IDeviceImportRecord> PreviousRecords, IDeviceImportDataReader DataReader, int ColumnIndex)
|
||||
{
|
||||
int? intValue;
|
||||
if (DataReader.TryGetNullableInt(ColumnIndex, out intValue))
|
||||
if (DataReader.TryGetNullableInt(ColumnIndex, out var intValue))
|
||||
{
|
||||
if (!intValue.HasValue)
|
||||
{
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
|
||||
public override bool Parse(DiscoDataContext Database, IDeviceImportCache Cache, IDeviceImportContext Context, string DeviceSerialNumber, Device ExistingDevice, List<IDeviceImportRecord> PreviousRecords, IDeviceImportDataReader DataReader, int ColumnIndex)
|
||||
{
|
||||
int? intValue;
|
||||
if (DataReader.TryGetNullableInt(ColumnIndex, out intValue))
|
||||
if (DataReader.TryGetNullableInt(ColumnIndex, out var intValue))
|
||||
{
|
||||
if (!intValue.HasValue)
|
||||
{
|
||||
|
||||
@@ -102,8 +102,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
int? value;
|
||||
return TryGetNullableInt(c, out value);
|
||||
return TryGetNullableInt(c, out var value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -112,8 +111,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
int? value;
|
||||
return TryGetNullableInt(c, out value) && value.HasValue;
|
||||
return TryGetNullableInt(c, out var value) && value.HasValue;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,8 +120,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
bool? value;
|
||||
return TryGetNullableBool(c, out value);
|
||||
return TryGetNullableBool(c, out var value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,8 +129,7 @@ namespace Disco.Services.Devices.Importing
|
||||
return rawData.Select(r => r[ColumnIndex])
|
||||
.All(c =>
|
||||
{
|
||||
DateTime? value;
|
||||
return TryGetNullableDateTime(c, out value);
|
||||
return TryGetNullableDateTime(c, out var value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,8 +163,7 @@ namespace Disco.Services.Devices.Importing
|
||||
{
|
||||
stringValue = stringValue.Trim();
|
||||
|
||||
DateTime valueDateTime;
|
||||
if (DateTime.TryParse(stringValue, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out valueDateTime))
|
||||
if (DateTime.TryParse(stringValue, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out var valueDateTime))
|
||||
{
|
||||
value = valueDateTime;
|
||||
return true;
|
||||
@@ -247,8 +242,7 @@ namespace Disco.Services.Devices.Importing
|
||||
}
|
||||
else
|
||||
{
|
||||
int intValue;
|
||||
if (int.TryParse(stringValue, out intValue))
|
||||
if (int.TryParse(stringValue, out var intValue))
|
||||
{
|
||||
value = intValue;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user