Shared.Models.Properties.IMetadataConfiguration
This commit is contained in:
@ -10,12 +10,12 @@ namespace View_by_Distance.Metadata.Models;
|
||||
public class A_Metadata
|
||||
{
|
||||
|
||||
private readonly IAAConfiguration _AAConfiguration;
|
||||
private readonly IMetadataConfiguration _AAConfiguration;
|
||||
private readonly bool _PropertiesChangedForMetadata;
|
||||
private readonly bool _ForceMetadataLastWriteTimeToCreationTime;
|
||||
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
|
||||
|
||||
public A_Metadata(IAAConfiguration aAConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata)
|
||||
public A_Metadata(IMetadataConfiguration aAConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata)
|
||||
{
|
||||
_AAConfiguration = aAConfiguration;
|
||||
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||
@ -29,14 +29,13 @@ public class A_Metadata
|
||||
_FileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(aAConfiguration, bResultsFullGroupDirectory, [aAConfiguration.ResultSingleton]);
|
||||
}
|
||||
|
||||
public ExifDirectory GetMetadataCollection(string file)
|
||||
public ExifDirectory GetMetadataCollection(IMetadataConfiguration metadataConfiguration, string file, NameWithoutExtension nameWithoutExtension)
|
||||
{
|
||||
ExifDirectory? results;
|
||||
string fileName = Path.GetFileName(file);
|
||||
string fileExtensionLowered = Path.GetExtension(file).ToLower();
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_AAConfiguration.ResultAllInOneSubdirectoryLength, fileName);
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_AAConfiguration.ResultSingleton][directoryIndex], $"{fileNameWithoutExtension}{fileExtensionLowered}.json"));
|
||||
FileInfo fileInfo = new(Path.Combine(_FileGroups[_AAConfiguration.ResultSingleton][directoryIndex], $"{nameWithoutExtension.FileNameWithoutExtension}{fileExtensionLowered}.json"));
|
||||
if (_ForceMetadataLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
@ -73,6 +72,8 @@ public class A_Metadata
|
||||
try
|
||||
{ size = Dimensions.GetDimensions(file); }
|
||||
catch (Exception) { size = null; }
|
||||
|
||||
|
||||
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(file);
|
||||
results = Exif.Covert(file, fileInfo, size, directories);
|
||||
string json = JsonSerializer.Serialize(results, ExifDirectorySourceGenerationContext.Default.ExifDirectory);
|
||||
@ -85,13 +86,15 @@ public class A_Metadata
|
||||
return results;
|
||||
}
|
||||
|
||||
public static Action<string> GetResultCollection(A_Metadata metadata, List<ExifDirectory> exifDirectories, Action tick)
|
||||
public static Action<string> GetResultCollection(IMetadataConfiguration metadataConfiguration, A_Metadata metadata, List<ExifDirectory> exifDirectories, Action tick)
|
||||
{
|
||||
return file =>
|
||||
{
|
||||
tick.Invoke();
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
NameWithoutExtension nameWithoutExtension = Shared.Models.Stateless.Methods.IId.GetNameWithoutExtension(metadataConfiguration, fileNameWithoutExtension);
|
||||
lock (exifDirectories)
|
||||
exifDirectories.Add(metadata.GetMetadataCollection(file));
|
||||
exifDirectories.Add(metadata.GetMetadataCollection(metadataConfiguration, file, nameWithoutExtension));
|
||||
};
|
||||
}
|
||||
|
||||
|
119
Metadata/Models/Binder/Configuration copy.cs
Normal file
119
Metadata/Models/Binder/Configuration copy.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// using Microsoft.Extensions.Configuration;
|
||||
// using System.Text.Json;
|
||||
// using System.Text.Json.Serialization;
|
||||
|
||||
// namespace View_by_Distance.Metadata.Models.Binder;
|
||||
|
||||
// public class ConfigurationZ
|
||||
// {
|
||||
|
||||
// public string? DateGroup { get; set; }
|
||||
// public string? FileNameDirectorySeparator { get; set; }
|
||||
// public bool? ForcePropertyLastWriteTimeToCreationTime { get; set; }
|
||||
// public string[]? IgnoreExtensions { get; set; }
|
||||
// public string[]? IgnoreRulesKeyWords { get; set; }
|
||||
// public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
|
||||
// public string? ModelName { init; get; }
|
||||
// public int? NumberOfJitters { init; get; }
|
||||
// public int? NumberOfTimesToUpsample { init; get; }
|
||||
// public int? Offset { init; get; }
|
||||
// public string? Pattern { get; set; }
|
||||
// public string? PersonBirthdayFormat { get; set; }
|
||||
// public bool? PopulatePropertyId { get; set; }
|
||||
// public string? PredictorModelName { get; set; }
|
||||
// public bool? PropertiesChangedForProperty { get; set; }
|
||||
// public string[]? PropertyContentCollectionFiles { get; set; }
|
||||
// public string? ResultAllInOne { get; set; }
|
||||
// public int? ResultAllInOneSubdirectoryLength { get; set; }
|
||||
// public string? ResultCollection { get; set; }
|
||||
// public string? ResultContent { get; set; }
|
||||
// public string? ResultSingleton { get; set; }
|
||||
// public string? RootDirectory { get; set; }
|
||||
// public string[]? ValidImageFormatExtensions { get; set; }
|
||||
|
||||
// public override string ToString()
|
||||
// {
|
||||
// string result = JsonSerializer.Serialize(this, BinderMetadataConfigurationSourceGenerationContext.Default.Configuration);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// private static MetadataConfiguration Get(Configuration? configuration)
|
||||
// {
|
||||
// MetadataConfiguration result;
|
||||
// if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||
// if (configuration.DateGroup is null) throw new NullReferenceException(nameof(configuration.DateGroup));
|
||||
// if (configuration.FileNameDirectorySeparator is null) throw new NullReferenceException(nameof(configuration.FileNameDirectorySeparator));
|
||||
// if (configuration.ForcePropertyLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForcePropertyLastWriteTimeToCreationTime));
|
||||
// if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
// if (configuration.IgnoreRulesKeyWords is null) throw new NullReferenceException(nameof(configuration.IgnoreRulesKeyWords));
|
||||
// if (configuration.MaxImagesInDirectoryForTopLevelFirstPass is null) throw new NullReferenceException(nameof(configuration.MaxImagesInDirectoryForTopLevelFirstPass));
|
||||
// // if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
|
||||
// // if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||
// // if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||
// if (configuration.Offset is null) throw new NullReferenceException(nameof(configuration.Offset)); ;
|
||||
// if (configuration.Pattern is null) throw new NullReferenceException(nameof(configuration.Pattern));
|
||||
// if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||
// if (configuration.PopulatePropertyId is null) throw new NullReferenceException(nameof(configuration.PopulatePropertyId));
|
||||
// // if (configuration.PredictorModelName is null) throw new NullReferenceException(nameof(configuration.PredictorModelName));
|
||||
// if (configuration.PropertiesChangedForProperty is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForProperty));
|
||||
// // if (configuration.PropertyContentCollectionFiles is null) throw new NullReferenceException(nameof(configuration.PropertyContentCollectionFiles));
|
||||
// if (configuration.ResultAllInOne is null) throw new NullReferenceException(nameof(configuration.ResultAllInOne));
|
||||
// if (configuration.ResultAllInOneSubdirectoryLength is null) throw new NullReferenceException(nameof(configuration.ResultAllInOneSubdirectoryLength));
|
||||
// if (configuration.ResultCollection is null) throw new NullReferenceException(nameof(configuration.ResultCollection));
|
||||
// if (configuration.ResultContent is null) throw new NullReferenceException(nameof(configuration.ResultContent));
|
||||
// if (configuration.ResultSingleton is null) throw new NullReferenceException(nameof(configuration.ResultSingleton));
|
||||
// if (configuration.RootDirectory is null) throw new NullReferenceException(nameof(configuration.RootDirectory));
|
||||
// if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
||||
// result = new(configuration.DateGroup,
|
||||
// configuration.FileNameDirectorySeparator,
|
||||
// configuration.ForcePropertyLastWriteTimeToCreationTime.Value,
|
||||
// configuration.IgnoreExtensions,
|
||||
// configuration.IgnoreRulesKeyWords,
|
||||
// configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
|
||||
// configuration.ModelName,
|
||||
// configuration.NumberOfJitters,
|
||||
// configuration.NumberOfTimesToUpsample,
|
||||
// configuration.Offset.Value,
|
||||
// configuration.Pattern,
|
||||
// configuration.PersonBirthdayFormat,
|
||||
// configuration.PopulatePropertyId.Value,
|
||||
// configuration.PredictorModelName,
|
||||
// configuration.PropertiesChangedForProperty.Value,
|
||||
// configuration.PropertyContentCollectionFiles ?? [],
|
||||
// configuration.ResultAllInOne,
|
||||
// configuration.ResultAllInOneSubdirectoryLength.Value,
|
||||
// configuration.ResultCollection,
|
||||
// configuration.ResultContent,
|
||||
// configuration.ResultSingleton,
|
||||
// Path.GetFullPath(configuration.RootDirectory),
|
||||
// configuration.ValidImageFormatExtensions);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// public static MetadataConfiguration Get(IConfigurationRoot configurationRoot)
|
||||
// {
|
||||
// MetadataConfiguration result;
|
||||
// #if Linux
|
||||
// string environmentName = "Linux";
|
||||
// #elif OSX
|
||||
// string environmentName = "OSX";
|
||||
// #elif Windows
|
||||
// string environmentName = "Windows";
|
||||
// #endif
|
||||
// string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||
// IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||
// #pragma warning disable IL3050, IL2026
|
||||
// Configuration? configuration = configurationSection.Get<Configuration>();
|
||||
// #pragma warning restore IL3050, IL2026
|
||||
// if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||
// result = Get(configuration);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// [JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
// [JsonSerializable(typeof(Configuration))]
|
||||
// internal partial class BinderMetadataConfigurationSourceGenerationContext : JsonSerializerContext
|
||||
// {
|
||||
// }
|
@ -8,17 +8,13 @@ public class Configuration
|
||||
{
|
||||
|
||||
public string? DateGroup { get; set; }
|
||||
public string? FileNameDirectorySeparator { get; set; }
|
||||
public bool? ForcePropertyLastWriteTimeToCreationTime { get; set; }
|
||||
public string[]? IgnoreExtensions { get; set; }
|
||||
public string[]? IgnoreRulesKeyWords { get; set; }
|
||||
public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
|
||||
public string? ModelName { init; get; }
|
||||
public int? NumberOfJitters { init; get; }
|
||||
public int? NumberOfTimesToUpsample { init; get; }
|
||||
public int? Offset { init; get; }
|
||||
public string? Pattern { get; set; }
|
||||
public string? PersonBirthdayFormat { get; set; }
|
||||
public bool? PopulatePropertyId { get; set; }
|
||||
public string? PredictorModelName { get; set; }
|
||||
public bool? PropertiesChangedForProperty { get; set; }
|
||||
@ -42,17 +38,13 @@ public class Configuration
|
||||
MetadataConfiguration result;
|
||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||
if (configuration.DateGroup is null) throw new NullReferenceException(nameof(configuration.DateGroup));
|
||||
if (configuration.FileNameDirectorySeparator is null) throw new NullReferenceException(nameof(configuration.FileNameDirectorySeparator));
|
||||
if (configuration.ForcePropertyLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForcePropertyLastWriteTimeToCreationTime));
|
||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.IgnoreRulesKeyWords is null) throw new NullReferenceException(nameof(configuration.IgnoreRulesKeyWords));
|
||||
if (configuration.MaxImagesInDirectoryForTopLevelFirstPass is null) throw new NullReferenceException(nameof(configuration.MaxImagesInDirectoryForTopLevelFirstPass));
|
||||
// if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
|
||||
// if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||
// if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||
if (configuration.Offset is null) throw new NullReferenceException(nameof(configuration.Offset)); ;
|
||||
if (configuration.Pattern is null) throw new NullReferenceException(nameof(configuration.Pattern));
|
||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||
if (configuration.PopulatePropertyId is null) throw new NullReferenceException(nameof(configuration.PopulatePropertyId));
|
||||
// if (configuration.PredictorModelName is null) throw new NullReferenceException(nameof(configuration.PredictorModelName));
|
||||
if (configuration.PropertiesChangedForProperty is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForProperty));
|
||||
@ -65,17 +57,13 @@ public class Configuration
|
||||
if (configuration.RootDirectory is null) throw new NullReferenceException(nameof(configuration.RootDirectory));
|
||||
if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
||||
result = new(configuration.DateGroup,
|
||||
configuration.FileNameDirectorySeparator,
|
||||
configuration.ForcePropertyLastWriteTimeToCreationTime.Value,
|
||||
configuration.IgnoreExtensions,
|
||||
configuration.IgnoreRulesKeyWords,
|
||||
configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
|
||||
configuration.ModelName,
|
||||
configuration.NumberOfJitters,
|
||||
configuration.NumberOfTimesToUpsample,
|
||||
configuration.Offset.Value,
|
||||
configuration.Pattern,
|
||||
configuration.PersonBirthdayFormat,
|
||||
configuration.PopulatePropertyId.Value,
|
||||
configuration.PredictorModelName,
|
||||
configuration.PropertiesChangedForProperty.Value,
|
||||
|
127
Metadata/Models/MetadataConfiguration copy.cs
Normal file
127
Metadata/Models/MetadataConfiguration copy.cs
Normal file
@ -0,0 +1,127 @@
|
||||
// using System.Text.Json;
|
||||
// using System.Text.Json.Serialization;
|
||||
|
||||
// namespace View_by_Distance.Metadata.Models;
|
||||
|
||||
// public class ZMetadataConfiguration : Shared.Models.Properties.IAAConfiguration
|
||||
// {
|
||||
|
||||
// protected string _RootDirectory;
|
||||
|
||||
// public string RootDirectory => _RootDirectory;
|
||||
|
||||
// public string DateGroup { init; get; }
|
||||
// public string FileNameDirectorySeparator { init; get; }
|
||||
// public bool ForcePropertyLastWriteTimeToCreationTime { init; get; }
|
||||
// public string[] IgnoreExtensions { init; get; }
|
||||
// public string[] IgnoreRulesKeyWords { init; get; }
|
||||
// public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
|
||||
// public string? ModelName { init; get; }
|
||||
// public int? NumberOfJitters { init; get; }
|
||||
// public int? NumberOfTimesToUpsample { init; get; }
|
||||
// public int Offset { init; get; }
|
||||
// public string Pattern { init; get; }
|
||||
// public string PersonBirthdayFormat { init; get; }
|
||||
// public bool PopulatePropertyId { init; get; }
|
||||
// public string? PredictorModelName { init; get; }
|
||||
// public bool PropertiesChangedForProperty { init; get; }
|
||||
// public string[] PropertyContentCollectionFiles { init; get; }
|
||||
// public string ResultAllInOne { init; get; }
|
||||
// public int ResultAllInOneSubdirectoryLength { init; get; }
|
||||
// public string ResultCollection { init; get; }
|
||||
// public string ResultContent { init; get; }
|
||||
// public string ResultSingleton { init; get; }
|
||||
// public string[] ValidImageFormatExtensions { init; get; }
|
||||
|
||||
// [JsonConstructor]
|
||||
// public MetadataConfiguration(string dateGroup,
|
||||
// string fileNameDirectorySeparator,
|
||||
// bool forcePropertyLastWriteTimeToCreationTime,
|
||||
// string[] ignoreExtensions,
|
||||
// string[] ignoreRulesKeyWords,
|
||||
// int maxImagesInDirectoryForTopLevelFirstPass,
|
||||
// string? modelName,
|
||||
// int? numberOfJitters,
|
||||
// int? numberOfTimesToUpsample,
|
||||
// int offset,
|
||||
// string pattern,
|
||||
// string personBirthdayFormat,
|
||||
// bool populatePropertyId,
|
||||
// string? predictorModelName,
|
||||
// bool propertiesChangedForProperty,
|
||||
// string[] propertyContentCollectionFiles,
|
||||
// string resultAllInOne,
|
||||
// int resultAllInOneSubdirectoryLength,
|
||||
// string resultCollection,
|
||||
// string resultContent,
|
||||
// string resultSingleton,
|
||||
// string rootDirectory,
|
||||
// string[] validImageFormatExtensions)
|
||||
// {
|
||||
// DateGroup = dateGroup;
|
||||
// FileNameDirectorySeparator = fileNameDirectorySeparator;
|
||||
// ForcePropertyLastWriteTimeToCreationTime = forcePropertyLastWriteTimeToCreationTime;
|
||||
// IgnoreExtensions = ignoreExtensions;
|
||||
// IgnoreRulesKeyWords = ignoreRulesKeyWords;
|
||||
// MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
|
||||
// ModelName = modelName;
|
||||
// NumberOfJitters = numberOfJitters;
|
||||
// NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
||||
// Offset = offset;
|
||||
// Pattern = pattern;
|
||||
// PersonBirthdayFormat = personBirthdayFormat;
|
||||
// PredictorModelName = predictorModelName;
|
||||
// PopulatePropertyId = populatePropertyId;
|
||||
// PropertiesChangedForProperty = propertiesChangedForProperty;
|
||||
// PropertyContentCollectionFiles = propertyContentCollectionFiles;
|
||||
// ResultAllInOne = resultAllInOne;
|
||||
// ResultAllInOneSubdirectoryLength = resultAllInOneSubdirectoryLength;
|
||||
// ResultCollection = resultCollection;
|
||||
// ResultContent = resultContent;
|
||||
// ResultSingleton = resultSingleton;
|
||||
// _RootDirectory = rootDirectory;
|
||||
// ValidImageFormatExtensions = validImageFormatExtensions;
|
||||
// }
|
||||
|
||||
// public override string ToString()
|
||||
// {
|
||||
// string result = JsonSerializer.Serialize(this, MetadataConfigurationSourceGenerationContext.Default.MetadataConfiguration);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// public void ChangeRootDirectory(string rootDirectory) =>
|
||||
// _RootDirectory = Path.GetFullPath(rootDirectory);
|
||||
|
||||
// public static void Verify(MetadataConfiguration propertyConfiguration, bool requireExist)
|
||||
// {
|
||||
// if (propertyConfiguration is null)
|
||||
// throw new NullReferenceException(nameof(propertyConfiguration));
|
||||
// if (propertyConfiguration.IgnoreExtensions is null || propertyConfiguration.IgnoreExtensions.Length == 0)
|
||||
// throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions));
|
||||
// if (propertyConfiguration.IgnoreRulesKeyWords is null || propertyConfiguration.IgnoreRulesKeyWords.Length == 0)
|
||||
// throw new NullReferenceException(nameof(propertyConfiguration.IgnoreRulesKeyWords));
|
||||
// if (propertyConfiguration.PropertyContentCollectionFiles is null)
|
||||
// throw new NullReferenceException(nameof(propertyConfiguration.PropertyContentCollectionFiles));
|
||||
// if (propertyConfiguration.ValidImageFormatExtensions is null || propertyConfiguration.ValidImageFormatExtensions.Length == 0)
|
||||
// throw new NullReferenceException(nameof(propertyConfiguration.ValidImageFormatExtensions));
|
||||
// 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();
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// [JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
// [JsonSerializable(typeof(MetadataConfiguration))]
|
||||
// internal partial class MetadataConfigurationSourceGenerationContext : JsonSerializerContext
|
||||
// {
|
||||
// }
|
@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Metadata.Models;
|
||||
|
||||
public class MetadataConfiguration : Shared.Models.Properties.IAAConfiguration
|
||||
public class MetadataConfiguration : Shared.Models.Properties.IMetadataConfiguration
|
||||
{
|
||||
|
||||
protected string _RootDirectory;
|
||||
@ -11,17 +11,13 @@ public class MetadataConfiguration : Shared.Models.Properties.IAAConfiguration
|
||||
public string RootDirectory => _RootDirectory;
|
||||
|
||||
public string DateGroup { init; get; }
|
||||
public string FileNameDirectorySeparator { init; get; }
|
||||
public bool ForcePropertyLastWriteTimeToCreationTime { init; get; }
|
||||
public string[] IgnoreExtensions { init; get; }
|
||||
public string[] IgnoreRulesKeyWords { init; get; }
|
||||
public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
|
||||
public string? ModelName { init; get; }
|
||||
public int? NumberOfJitters { init; get; }
|
||||
public int? NumberOfTimesToUpsample { init; get; }
|
||||
public int Offset { init; get; }
|
||||
public string Pattern { init; get; }
|
||||
public string PersonBirthdayFormat { init; get; }
|
||||
public bool PopulatePropertyId { init; get; }
|
||||
public string? PredictorModelName { init; get; }
|
||||
public bool PropertiesChangedForProperty { init; get; }
|
||||
@ -35,41 +31,33 @@ public class MetadataConfiguration : Shared.Models.Properties.IAAConfiguration
|
||||
|
||||
[JsonConstructor]
|
||||
public MetadataConfiguration(string dateGroup,
|
||||
string fileNameDirectorySeparator,
|
||||
bool forcePropertyLastWriteTimeToCreationTime,
|
||||
string[] ignoreExtensions,
|
||||
string[] ignoreRulesKeyWords,
|
||||
int maxImagesInDirectoryForTopLevelFirstPass,
|
||||
string? modelName,
|
||||
int? numberOfJitters,
|
||||
int? numberOfTimesToUpsample,
|
||||
int offset,
|
||||
string pattern,
|
||||
string personBirthdayFormat,
|
||||
bool populatePropertyId,
|
||||
string? predictorModelName,
|
||||
bool propertiesChangedForProperty,
|
||||
string[] propertyContentCollectionFiles,
|
||||
string resultAllInOne,
|
||||
int resultAllInOneSubdirectoryLength,
|
||||
string resultCollection,
|
||||
string resultContent,
|
||||
string resultSingleton,
|
||||
string rootDirectory,
|
||||
string[] validImageFormatExtensions)
|
||||
bool forcePropertyLastWriteTimeToCreationTime,
|
||||
string[] ignoreExtensions,
|
||||
int maxImagesInDirectoryForTopLevelFirstPass,
|
||||
string? modelName,
|
||||
int? numberOfJitters,
|
||||
int? numberOfTimesToUpsample,
|
||||
int offset,
|
||||
bool populatePropertyId,
|
||||
string? predictorModelName,
|
||||
bool propertiesChangedForProperty,
|
||||
string[] propertyContentCollectionFiles,
|
||||
string resultAllInOne,
|
||||
int resultAllInOneSubdirectoryLength,
|
||||
string resultCollection,
|
||||
string resultContent,
|
||||
string resultSingleton,
|
||||
string rootDirectory,
|
||||
string[] validImageFormatExtensions)
|
||||
{
|
||||
DateGroup = dateGroup;
|
||||
FileNameDirectorySeparator = fileNameDirectorySeparator;
|
||||
ForcePropertyLastWriteTimeToCreationTime = forcePropertyLastWriteTimeToCreationTime;
|
||||
IgnoreExtensions = ignoreExtensions;
|
||||
IgnoreRulesKeyWords = ignoreRulesKeyWords;
|
||||
MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
|
||||
ModelName = modelName;
|
||||
NumberOfJitters = numberOfJitters;
|
||||
NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
||||
Offset = offset;
|
||||
Pattern = pattern;
|
||||
PersonBirthdayFormat = personBirthdayFormat;
|
||||
PredictorModelName = predictorModelName;
|
||||
PopulatePropertyId = populatePropertyId;
|
||||
PropertiesChangedForProperty = propertiesChangedForProperty;
|
||||
@ -92,29 +80,23 @@ public class MetadataConfiguration : Shared.Models.Properties.IAAConfiguration
|
||||
public void ChangeRootDirectory(string rootDirectory) =>
|
||||
_RootDirectory = Path.GetFullPath(rootDirectory);
|
||||
|
||||
public static void Verify(MetadataConfiguration propertyConfiguration, bool requireExist)
|
||||
public static void Verify(Shared.Models.Properties.IMetadataConfiguration metadataConfiguration, bool requireExist)
|
||||
{
|
||||
if (propertyConfiguration is null)
|
||||
throw new NullReferenceException(nameof(propertyConfiguration));
|
||||
if (propertyConfiguration.IgnoreExtensions is null || propertyConfiguration.IgnoreExtensions.Length == 0)
|
||||
throw new NullReferenceException(nameof(propertyConfiguration.IgnoreExtensions));
|
||||
if (propertyConfiguration.IgnoreRulesKeyWords is null || propertyConfiguration.IgnoreRulesKeyWords.Length == 0)
|
||||
throw new NullReferenceException(nameof(propertyConfiguration.IgnoreRulesKeyWords));
|
||||
if (propertyConfiguration.PropertyContentCollectionFiles is null)
|
||||
throw new NullReferenceException(nameof(propertyConfiguration.PropertyContentCollectionFiles));
|
||||
if (propertyConfiguration.ValidImageFormatExtensions is null || propertyConfiguration.ValidImageFormatExtensions.Length == 0)
|
||||
throw new NullReferenceException(nameof(propertyConfiguration.ValidImageFormatExtensions));
|
||||
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))
|
||||
if (metadataConfiguration is null)
|
||||
throw new NullReferenceException(nameof(metadataConfiguration));
|
||||
if (metadataConfiguration.IgnoreExtensions is null || metadataConfiguration.IgnoreExtensions.Length == 0)
|
||||
throw new NullReferenceException(nameof(metadataConfiguration.IgnoreExtensions));
|
||||
if (metadataConfiguration.PropertyContentCollectionFiles is null)
|
||||
throw new NullReferenceException(nameof(metadataConfiguration.PropertyContentCollectionFiles));
|
||||
if (metadataConfiguration.ValidImageFormatExtensions is null || metadataConfiguration.ValidImageFormatExtensions.Length == 0)
|
||||
throw new NullReferenceException(nameof(metadataConfiguration.ValidImageFormatExtensions));
|
||||
if (metadataConfiguration is null)
|
||||
throw new NullReferenceException(nameof(metadataConfiguration));
|
||||
if (string.IsNullOrEmpty(metadataConfiguration.DateGroup))
|
||||
throw new NullReferenceException(nameof(metadataConfiguration.DateGroup));
|
||||
if (string.IsNullOrEmpty(metadataConfiguration.RootDirectory) || (requireExist && !Directory.Exists(metadataConfiguration.RootDirectory)))
|
||||
throw new NullReferenceException(nameof(metadataConfiguration.RootDirectory));
|
||||
if (metadataConfiguration.RootDirectory != Path.GetFullPath(metadataConfiguration.RootDirectory))
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user