AOT Builds
This commit is contained in:
2
Metadata/Models/Binder/.editorconfig
Normal file
2
Metadata/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
||||
[*.cs]
|
||||
csharp_preserve_single_line_statements = true
|
119
Metadata/Models/Binder/Configuration.cs
Normal file
119
Metadata/Models/Binder/Configuration.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 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; }
|
||||
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
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user