This commit is contained in:
Mike Phares 2023-10-15 12:15:22 -07:00
parent 37b7ad2a1f
commit d17b051da7
10 changed files with 247 additions and 234 deletions

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace View_by_Distance.Metadata.Models; namespace View_by_Distance.Metadata.Models;
public record Avi(string? FramesPerSecond1, public record Avi(string? FramesPerSecond1,
string? SamplesPerSecond2, string? SamplesPerSecond2,
string? Duration3, string? Duration3,
string? VideoCodec4, string? VideoCodec4,

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace View_by_Distance.Metadata.Models; namespace View_by_Distance.Metadata.Models;
public record Exif(string? InteropIndex1, public record Exif(string? InteropIndex1,
string? Noise37389, string? Noise37389,
string? FocalPlaneXResolutionTiffEp37390, string? FocalPlaneXResolutionTiffEp37390,
string? FocalPlaneYResolutionTiffEp37391, string? FocalPlaneYResolutionTiffEp37391,

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace View_by_Distance.Metadata.Models; namespace View_by_Distance.Metadata.Models;
public record QuickTimeMovieHeader(string? Version1, public record QuickTimeMovieHeader(string? Version1,
string? NextTrackId16, string? NextTrackId16,
string? CurrentTime15, string? CurrentTime15,
string? SelectionDuration14, string? SelectionDuration14,

View File

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace View_by_Distance.Metadata.Models; namespace View_by_Distance.Metadata.Models;
public record QuickTimeTrackHeader(string? Version1, public record QuickTimeTrackHeader(string? Version1,
string? Flags2, string? Flags2,
string? Created3, string? Created3,
string? Modified4, string? Modified4,

View File

@ -16,7 +16,8 @@ public abstract class Configuration
Binder.Configuration? configuration = configurationSection.Get<Binder.Configuration>(); Binder.Configuration? configuration = configurationSection.Get<Binder.Configuration>();
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true }); string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
result = JsonSerializer.Deserialize<Models.Configuration>(json); result = JsonSerializer.Deserialize<Models.Configuration>(json);
if (result is null) throw new Exception(json); if (result is null)
throw new Exception(json);
string jsonThis = result.ToString(); string jsonThis = result.ToString();
if (jsonThis != json) if (jsonThis != json)
{ {
@ -29,10 +30,11 @@ public abstract class Configuration
check = i; check = i;
break; break;
} }
if (check is null) throw new Exception(); if (check is null)
throw new Exception();
string a = json[..check.Value].Split(',')[^1]; string a = json[..check.Value].Split(',')[^1];
string b = json[check.Value..].Split(',')[0]; string b = json[check.Value..].Split(',')[0];
throw new Exception($"{a}{b}"); throw new Exception($"{a}{b}");
} }
return result; return result;
} }

View File

@ -51,7 +51,7 @@ public class Configuration
// if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName)); // if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
// if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters)); // if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
// if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample)); // if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
if (configuration.Offset is null) throw new NullReferenceException(nameof(configuration.Offset));; if (configuration.Offset is null) throw new NullReferenceException(nameof(configuration.Offset)); ;
if (configuration.Pattern is null) throw new NullReferenceException(nameof(configuration.Pattern)); if (configuration.Pattern is null) throw new NullReferenceException(nameof(configuration.Pattern));
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat)); if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
if (configuration.PopulatePropertyId is null) throw new NullReferenceException(nameof(configuration.PopulatePropertyId)); if (configuration.PopulatePropertyId is null) throw new NullReferenceException(nameof(configuration.PopulatePropertyId));

View File

@ -95,17 +95,28 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
public static void Verify(Configuration propertyConfiguration, bool requireExist) public static void Verify(Configuration propertyConfiguration, bool requireExist)
{ {
if (propertyConfiguration is null) throw new NullReferenceException(nameof(propertyConfiguration)); if (propertyConfiguration is null)
if (propertyConfiguration.IgnoreExtensions is null || propertyConfiguration.IgnoreExtensions.Length == 0) throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions)); throw new NullReferenceException(nameof(propertyConfiguration));
if (propertyConfiguration.IgnoreRulesKeyWords is null || propertyConfiguration.IgnoreRulesKeyWords.Length == 0) throw new NullReferenceException(nameof(propertyConfiguration.IgnoreRulesKeyWords)); if (propertyConfiguration.IgnoreExtensions is null || propertyConfiguration.IgnoreExtensions.Length == 0)
if (propertyConfiguration.PropertyContentCollectionFiles is null) throw new NullReferenceException(nameof(propertyConfiguration.PropertyContentCollectionFiles)); throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions));
if (propertyConfiguration.ValidImageFormatExtensions is null || propertyConfiguration.ValidImageFormatExtensions.Length == 0) throw new NullReferenceException(nameof(propertyConfiguration.ValidImageFormatExtensions)); if (propertyConfiguration.IgnoreRulesKeyWords is null || propertyConfiguration.IgnoreRulesKeyWords.Length == 0)
if (propertyConfiguration is null) throw new NullReferenceException(nameof(propertyConfiguration)); throw new NullReferenceException(nameof(propertyConfiguration.IgnoreRulesKeyWords));
if (string.IsNullOrEmpty(propertyConfiguration.DateGroup)) throw new NullReferenceException(nameof(propertyConfiguration.DateGroup)); if (propertyConfiguration.PropertyContentCollectionFiles is null)
if (string.IsNullOrEmpty(propertyConfiguration.FileNameDirectorySeparator)) throw new NullReferenceException(nameof(propertyConfiguration.FileNameDirectorySeparator)); throw new NullReferenceException(nameof(propertyConfiguration.PropertyContentCollectionFiles));
if (string.IsNullOrEmpty(propertyConfiguration.Pattern)) throw new NullReferenceException(nameof(propertyConfiguration.Pattern)); if (propertyConfiguration.ValidImageFormatExtensions is null || propertyConfiguration.ValidImageFormatExtensions.Length == 0)
if (string.IsNullOrEmpty(propertyConfiguration.RootDirectory) || (requireExist && !Directory.Exists(propertyConfiguration.RootDirectory))) throw new NullReferenceException(nameof(propertyConfiguration.RootDirectory)); throw new NullReferenceException(nameof(propertyConfiguration.ValidImageFormatExtensions));
if (propertyConfiguration.RootDirectory != Path.GetFullPath(propertyConfiguration.RootDirectory)) throw new Exception(); if (propertyConfiguration is null)
throw new NullReferenceException(nameof(propertyConfiguration));
if (string.IsNullOrEmpty(propertyConfiguration.DateGroup))
throw new NullReferenceException(nameof(propertyConfiguration.DateGroup));
if (string.IsNullOrEmpty(propertyConfiguration.FileNameDirectorySeparator))
throw new NullReferenceException(nameof(propertyConfiguration.FileNameDirectorySeparator));
if (string.IsNullOrEmpty(propertyConfiguration.Pattern))
throw new NullReferenceException(nameof(propertyConfiguration.Pattern));
if (string.IsNullOrEmpty(propertyConfiguration.RootDirectory) || (requireExist && !Directory.Exists(propertyConfiguration.RootDirectory)))
throw new NullReferenceException(nameof(propertyConfiguration.RootDirectory));
if (propertyConfiguration.RootDirectory != Path.GetFullPath(propertyConfiguration.RootDirectory))
throw new Exception();
} }
} }