Skip to content
Snippets Groups Projects
Commit 43c621db authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add block comments to denote sequence of validation checks.

parent 7dc0494d
Branches
Tags
No related merge requests found
...@@ -351,6 +351,7 @@ namespace ATxCommon.Serializables ...@@ -351,6 +351,7 @@ namespace ATxCommon.Serializables
throw new ConfigurationErrorsException(msg); throw new ConfigurationErrorsException(msg);
} }
// check if all required parameters are there and non-empty / non-zero:
errmsg += CheckEmpty(c.HostAlias, nameof(c.HostAlias)); errmsg += CheckEmpty(c.HostAlias, nameof(c.HostAlias));
errmsg += CheckEmpty(c.SourceDrive, nameof(c.SourceDrive)); errmsg += CheckEmpty(c.SourceDrive, nameof(c.SourceDrive));
errmsg += CheckEmpty(c.IncomingDirectory, nameof(c.IncomingDirectory)); errmsg += CheckEmpty(c.IncomingDirectory, nameof(c.IncomingDirectory));
...@@ -363,11 +364,14 @@ namespace ATxCommon.Serializables ...@@ -363,11 +364,14 @@ namespace ATxCommon.Serializables
errmsg += CheckMinValue(c.MaxCpuUsage, nameof(c.MaxCpuUsage), 5); errmsg += CheckMinValue(c.MaxCpuUsage, nameof(c.MaxCpuUsage), 5);
errmsg += CheckMinValue(c.MinAvailableMemory, nameof(c.MinAvailableMemory), 256); errmsg += CheckMinValue(c.MinAvailableMemory, nameof(c.MinAvailableMemory), 256);
// if any of the above detected invalid settings we terminate now as many of the // if any of the required parameter checks failed we terminate now as many of the
// string checks below would fail on empty strings: // string checks below would fail on empty strings:
if (!string.IsNullOrWhiteSpace(errmsg)) if (!string.IsNullOrWhiteSpace(errmsg))
LogAndThrow(errmsg); LogAndThrow(errmsg);
////////// REQUIRED PARAMETERS SETTINGS VALIDATION //////////
// SourceDrive // SourceDrive
if (c.SourceDrive.Substring(1) != @":\") if (c.SourceDrive.Substring(1) != @":\")
errmsg += "SourceDrive must be of form [X:\\]\n!"; errmsg += "SourceDrive must be of form [X:\\]\n!";
...@@ -388,16 +392,22 @@ namespace ATxCommon.Serializables ...@@ -388,16 +392,22 @@ namespace ATxCommon.Serializables
if (!Directory.Exists(tmpTransferPath)) if (!Directory.Exists(tmpTransferPath))
errmsg += $"can't find (or reach) temporary transfer dir: {tmpTransferPath}\n"; errmsg += $"can't find (or reach) temporary transfer dir: {tmpTransferPath}\n";
////////// OPTIONAL PARAMETERS SETTINGS VALIDATION //////////
// DriveName // DriveName
foreach (var driveToCheck in c.SpaceMonitoring) { foreach (var driveToCheck in c.SpaceMonitoring) {
errmsg += CheckLocalDrive(driveToCheck.DriveName, nameof(driveToCheck.DriveName)); errmsg += CheckLocalDrive(driveToCheck.DriveName, nameof(driveToCheck.DriveName));
} }
// NON-CRITICAL stuff is simply reported to the logs: ////////// WEAK CHECKS ON PARAMETERS SETTINGS //////////
// those checks are non-critical and are simply reported to the logs
if (!c.DestinationDirectory.StartsWith(@"\\")) if (!c.DestinationDirectory.StartsWith(@"\\"))
SubOptimal("DestinationDirectory", c.DestinationDirectory, "is not a UNC path!"); SubOptimal("DestinationDirectory", c.DestinationDirectory, "is not a UNC path!");
if (string.IsNullOrWhiteSpace(errmsg)) if (string.IsNullOrWhiteSpace(errmsg))
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment