NullReferenceException

This commit is contained in:
2022-08-13 11:19:08 -07:00
parent 3aeab88384
commit 0392de1920
33 changed files with 1278 additions and 1030 deletions

View File

@ -28,7 +28,7 @@ public class NotCopyCopy
{ }
_AppSettings = appSettings;
if (appSettings.MaxDegreeOfParallelism is null)
throw new ArgumentNullException(nameof(appSettings.MaxDegreeOfParallelism));
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
_IsEnvironment = isEnvironment;
_Exceptions = new List<string>();
_Log = Serilog.Log.ForContext<NotCopyCopy>();
@ -43,15 +43,15 @@ public class NotCopyCopy
PredictorModel? predictorModel = null;
_Configuration = configuration;
if (propertyConfiguration.PopulatePropertyId is null)
throw new ArgumentNullException(nameof(propertyConfiguration.PopulatePropertyId));
throw new NullReferenceException(nameof(propertyConfiguration.PopulatePropertyId));
if (!_IsEnvironment.Development)
throw new Exception("This program only allows development environments!");
PropertyLogic propertyLogic = GetPropertyLogic();
PropertyLogic propertyLogic = GetPropertyLogic(reverse, model, predictorModel);
propertyConfiguration.ChangeRootDirectory(configuration.CompareSource);
List<PropertyHolder[]> comparePropertyHolderCollections = Property.Models.Stateless.A_Property.Get(propertyConfiguration, reverse, model, predictorModel, propertyLogic);
List<Container> compareContainers = Property.Models.Stateless.A_Property.Get(propertyConfiguration, propertyLogic);
propertyConfiguration.ChangeRootDirectory(configuration.SelectedSource);
List<PropertyHolder[]> selectedPropertyHolderCollections = Property.Models.Stateless.A_Property.Get(propertyConfiguration, reverse, model, predictorModel, propertyLogic);
if (comparePropertyHolderCollections.Count == selectedPropertyHolderCollections.Count)
List<Container> selectedContainers = Property.Models.Stateless.A_Property.Get(propertyConfiguration, propertyLogic);
if (compareContainers.Count == selectedContainers.Count)
throw new Exception();
string directoryName;
List<string> distinct = new();
@ -100,36 +100,36 @@ public class NotCopyCopy
private static void Verify(Models.Configuration configuration)
{
if (Path.GetPathRoot(configuration.SelectedSource) == configuration.SelectedSource)
throw new ArgumentNullException(nameof(configuration.SelectedSource));
throw new NullReferenceException(nameof(configuration.SelectedSource));
if (string.IsNullOrEmpty(configuration.CompareSource) || !Directory.Exists(configuration.CompareSource))
throw new ArgumentNullException(nameof(configuration.CompareSource));
throw new NullReferenceException(nameof(configuration.CompareSource));
if (string.IsNullOrEmpty(configuration.EmptyDestination) || Directory.Exists(configuration.EmptyDestination))
throw new ArgumentNullException(nameof(configuration.EmptyDestination));
throw new NullReferenceException(nameof(configuration.EmptyDestination));
if (string.IsNullOrEmpty(configuration.SelectedSource) || !Directory.Exists(configuration.SelectedSource))
throw new ArgumentNullException(nameof(configuration.SelectedSource));
throw new NullReferenceException(nameof(configuration.SelectedSource));
if (configuration.SelectedSource.Length != configuration.CompareSource.Length)
throw new ArgumentNullException(nameof(configuration.SelectedSource));
throw new NullReferenceException(nameof(configuration.SelectedSource));
}
private long LogDelta(long ticks, string methodName)
{
long result;
if (_Log is null)
throw new ArgumentNullException(nameof(_Log));
throw new NullReferenceException(nameof(_Log));
double delta = new TimeSpan(DateTime.Now.Ticks - ticks).TotalMilliseconds;
_Log.Debug($"{methodName} took {Math.Floor(delta)} millisecond(s)");
result = DateTime.Now.Ticks;
return result;
}
private PropertyLogic GetPropertyLogic()
private PropertyLogic GetPropertyLogic(bool reverse, Model? model, PredictorModel? predictorModel)
{
PropertyLogic result;
if (_AppSettings.MaxDegreeOfParallelism is null)
throw new ArgumentNullException(nameof(_AppSettings.MaxDegreeOfParallelism));
throw new NullReferenceException(nameof(_AppSettings.MaxDegreeOfParallelism));
if (_Configuration?.PropertyConfiguration is null)
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration, reverse, model, predictorModel);
return result;
}
@ -137,7 +137,7 @@ public class NotCopyCopy
{
List<(string Source, string[] Destination)> results = new();
if (_Configuration?.PropertyConfiguration is null)
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
string key;
string fileName;
A_Property? property;