General code refactor.

This commit is contained in:
2020-12-21 02:31:12 +00:00
parent 8092a0be62
commit 88944ca4dc
8 changed files with 28 additions and 26 deletions

View File

@@ -362,7 +362,7 @@ namespace Aaru.Server.Areas.Admin.Controllers
public IActionResult CheckPrivate()
{
List<Ata> havePrivacy = new List<Ata>();
List<Ata> havePrivacy = new();
byte[] tmp;
foreach(Ata ata in _context.Ata)

View File

@@ -137,7 +137,7 @@ namespace Aaru.Server.Controllers
if(tuples != null)
{
Dictionary<string, string> decodedTuples = new Dictionary<string, string>();
Dictionary<string, string> decodedTuples = new();
foreach(Tuple tuple in tuples)
switch(tuple.Code)
@@ -226,8 +226,8 @@ namespace Aaru.Server.Controllers
if(report.ATA != null ||
report.ATAPI != null)
{
List<string> ataOneValue = new List<string>();
Dictionary<string, string> ataTwoValue = new Dictionary<string, string>();
List<string> ataOneValue = new();
Dictionary<string, string> ataTwoValue = new();
Ata ataReport;
if(report.ATAPI != null)
@@ -260,9 +260,9 @@ namespace Aaru.Server.Controllers
if(report.SCSI != null)
{
List<string> scsiOneValue = new List<string>();
Dictionary<string, string> modePages = new Dictionary<string, string>();
Dictionary<string, string> evpdPages = new Dictionary<string, string>();
List<string> scsiOneValue = new();
Dictionary<string, string> modePages = new();
Dictionary<string, string> evpdPages = new();
string vendorId = StringHandlers.CToString(report.SCSI.Inquiry?.VendorIdentification);
@@ -313,7 +313,7 @@ namespace Aaru.Server.Controllers
if(report.SCSI.MultiMediaDevice.ModeSense2A != null)
{
List<string> mmcModeOneValue = new List<string>();
List<string> mmcModeOneValue = new();
ScsiMmcMode.Report(report.SCSI.MultiMediaDevice.ModeSense2A, ref mmcModeOneValue);
if(mmcModeOneValue.Count > 0)
@@ -322,7 +322,7 @@ namespace Aaru.Server.Controllers
if(report.SCSI.MultiMediaDevice.Features != null)
{
List<string> mmcFeaturesOneValue = new List<string>();
List<string> mmcFeaturesOneValue = new();
ScsiMmcFeatures.Report(report.SCSI.MultiMediaDevice.Features, ref mmcFeaturesOneValue);
if(mmcFeaturesOneValue.Count > 0)
@@ -350,7 +350,7 @@ namespace Aaru.Server.Controllers
if(report.SCSI.SequentialDevice.TestedMedia != null)
{
List<string> mediaOneValue = new List<string>();
List<string> mediaOneValue = new();
SscTestedMedia.Report(report.SCSI.SequentialDevice.TestedMedia, ref mediaOneValue);
if(mediaOneValue.Count > 0)
@@ -429,7 +429,7 @@ namespace Aaru.Server.Controllers
if(report.MultiMediaCard != null)
{
List<string> mmcOneValue = new List<string>();
List<string> mmcOneValue = new();
if(report.MultiMediaCard.CID != null)
{
@@ -468,7 +468,7 @@ namespace Aaru.Server.Controllers
if(report.SecureDigital != null)
{
List<string> sdOneValue = new List<string>();
List<string> sdOneValue = new();
if(report.SecureDigital.CID != null)
{
@@ -509,7 +509,7 @@ namespace Aaru.Server.Controllers
!sscMedia &&
testedMedia != null)
{
List<string> mediaOneValue = new List<string>();
List<string> mediaOneValue = new();
Core.TestedMedia.Report(testedMedia, ref mediaOneValue);
if(mediaOneValue.Count > 0)

View File

@@ -96,7 +96,7 @@ namespace Aaru.Server.Controllers
if(_ctx.OperatingSystems.Any())
{
List<NameValueStats> operatingSystems = new List<NameValueStats>();
List<NameValueStats> operatingSystems = new();
foreach(OperatingSystem nvs in _ctx.OperatingSystems)
operatingSystems.Add(new NameValueStats
@@ -111,7 +111,7 @@ namespace Aaru.Server.Controllers
if(_ctx.Versions.Any())
{
List<NameValueStats> versions = new List<NameValueStats>();
List<NameValueStats> versions = new();
foreach(Version nvs in _ctx.Versions)
versions.Add(new NameValueStats
@@ -140,8 +140,8 @@ namespace Aaru.Server.Controllers
if(_ctx.Medias.Any())
{
List<MediaItem> realMedia = new List<MediaItem>();
List<MediaItem> virtualMedia = new List<MediaItem>();
List<MediaItem> realMedia = new();
List<MediaItem> virtualMedia = new();
foreach(Media nvs in _ctx.Medias)
try
@@ -194,7 +194,7 @@ namespace Aaru.Server.Controllers
if(_ctx.DeviceStats.Any())
{
List<DeviceItem> devices = new List<DeviceItem>();
List<DeviceItem> devices = new();
foreach(DeviceStat device in _ctx.DeviceStats.ToList())
{

View File

@@ -45,7 +45,7 @@ namespace Aaru.Server.Core
/// <returns>List of values</returns>
internal static IEnumerable<string> Report(Inquiry? inquiryNullable)
{
List<string> scsiOneValue = new List<string>();
List<string> scsiOneValue = new();
if(!inquiryNullable.HasValue)
return scsiOneValue;

View File

@@ -418,7 +418,7 @@ namespace Aaru.Server.Core
break;
}
Dictionary<string, string> newModePages = new Dictionary<string, string>();
Dictionary<string, string> newModePages = new();
foreach(KeyValuePair<string, string> kvp in modePages)
newModePages.Add(kvp.Key,

View File

@@ -87,10 +87,10 @@ namespace Aaru.Server.Models
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
IConfigurationRoot configuration = builder.Build();
optionsBuilder.
UseMySql(configuration.GetConnectionString("DefaultConnection"),
new MariaDbServerVersion(new System.Version(10, 4, 0))).
UseLazyLoadingProxies();
new MariaDbServerVersion(new System.Version(10, 4, 0))).UseLazyLoadingProxies();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)

View File

@@ -19,7 +19,7 @@ namespace Aaru.Server
randChars[i] = (char)rnd.Next(32, 126);
}
string password = new string(randChars);
string password = new(randChars);
if(userManager.FindByEmailAsync(email).Result != null)
return;

View File

@@ -9,6 +9,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Prometheus;
using Version = System.Version;
namespace Aaru.Server
{
@@ -22,9 +23,10 @@ namespace Aaru.Server
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AaruServerContext>(options => options.
UseMySql(Configuration.GetConnectionString("DefaultConnection"),
new MariaDbServerVersion(new System.Version(10,
4, 0))).UseLazyLoadingProxies());
UseMySql(Configuration.GetConnectionString("DefaultConnection"),
new MariaDbServerVersion(new Version(10, 4,
0))).
UseLazyLoadingProxies());
services.AddDefaultIdentity<IdentityUser>(options =>
{