RelativePropertyCollectionFile
aMetadataCollectionDirectory Work with video FilePath.IsIgnore Removed IId IsIgnore Keywords RootAmazon SaveAmazon PhysicalFileProvider Message Bump HarFilesDirectory
This commit is contained in:
@ -4,6 +4,7 @@ using System.Text.Json.Serialization;
|
||||
namespace View_by_Distance.Rename.Models;
|
||||
|
||||
public record AppSettings(string Company,
|
||||
string? HarFilesDirectory,
|
||||
int MaxDegreeOfParallelism,
|
||||
bool RequireRootDirectoryExists)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ public class AppSettings
|
||||
{
|
||||
|
||||
public string? Company { get; set; }
|
||||
public string? HarFilesDirectory { get; set; }
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public bool? RequireRootDirectoryExists { get; set; }
|
||||
|
||||
@ -21,17 +22,16 @@ public class AppSettings
|
||||
{
|
||||
if (appSettings?.Company is null)
|
||||
{
|
||||
List<string> paths = [];
|
||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||
{
|
||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||
continue;
|
||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||
continue;
|
||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
||||
continue;
|
||||
throw new NotSupportedException(physicalFileProvider.Root);
|
||||
paths.Add(physicalFileProvider.Root);
|
||||
}
|
||||
throw new NotSupportedException("Not Found!");
|
||||
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ public class AppSettings
|
||||
if (appSettings.RequireRootDirectoryExists is null) throw new NullReferenceException(nameof(appSettings.RequireRootDirectoryExists));
|
||||
Verify(appSettings);
|
||||
result = new(appSettings.Company,
|
||||
appSettings.HarFilesDirectory,
|
||||
appSettings.MaxDegreeOfParallelism.Value,
|
||||
appSettings.RequireRootDirectoryExists.Value);
|
||||
return result;
|
||||
|
@ -7,8 +7,10 @@ namespace View_by_Distance.Rename.Models.Binder;
|
||||
public class RenameConfiguration
|
||||
{
|
||||
|
||||
public string? DefaultMaker { get; set; }
|
||||
public bool? ForceNewId { get; set; }
|
||||
public string[]? IgnoreExtensions { get; set; }
|
||||
public bool? MoveFilesToRoot { get; set; }
|
||||
public string? RelativePropertyCollectionFile { get; set; }
|
||||
public bool? SkipIdFiles { get; set; }
|
||||
public string[]? ValidImageFormatExtensions { get; set; }
|
||||
public string[]? ValidVideoFormatExtensions { get; set; }
|
||||
@ -21,19 +23,18 @@ public class RenameConfiguration
|
||||
|
||||
private static void PreVerify(IConfigurationRoot configurationRoot, RenameConfiguration? configuration)
|
||||
{
|
||||
if (configuration?.IgnoreExtensions is null)
|
||||
if (configuration?.DefaultMaker is null)
|
||||
{
|
||||
List<string> paths = [];
|
||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||
{
|
||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||
continue;
|
||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||
continue;
|
||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
||||
continue;
|
||||
throw new NotSupportedException(physicalFileProvider.Root);
|
||||
paths.Add(physicalFileProvider.Root);
|
||||
}
|
||||
throw new NotSupportedException("Not Found!");
|
||||
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,15 +49,19 @@ public class RenameConfiguration
|
||||
{
|
||||
Models.RenameConfiguration result;
|
||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||
if (configuration.DefaultMaker is null) throw new NullReferenceException(nameof(configuration.DefaultMaker));
|
||||
if (configuration.ForceNewId is null) throw new NullReferenceException(nameof(configuration.ForceNewId));
|
||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.MoveFilesToRoot is null) throw new NullReferenceException(nameof(configuration.MoveFilesToRoot));
|
||||
if (configuration.RelativePropertyCollectionFile is null) throw new NullReferenceException(nameof(configuration.RelativePropertyCollectionFile));
|
||||
if (configuration.SkipIdFiles is null) throw new NullReferenceException(nameof(configuration.SkipIdFiles));
|
||||
if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
||||
if (configuration.ValidVideoFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidVideoFormatExtensions));
|
||||
Verify(configuration);
|
||||
result = new(metadataConfiguration,
|
||||
configuration.DefaultMaker,
|
||||
configuration.ForceNewId.Value,
|
||||
configuration.IgnoreExtensions,
|
||||
configuration.MoveFilesToRoot.Value,
|
||||
configuration.RelativePropertyCollectionFile,
|
||||
configuration.SkipIdFiles.Value,
|
||||
configuration.ValidImageFormatExtensions,
|
||||
configuration.ValidVideoFormatExtensions);
|
||||
|
27
Rename/Models/Identifier.cs
Normal file
27
Rename/Models/Identifier.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Rename.Models;
|
||||
|
||||
internal record Identifier(int Id, string PaddedId)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, IdentifierSourceGenerationContext.Default.Identifier);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(Identifier))]
|
||||
internal partial class IdentifierSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(Identifier[]))]
|
||||
internal partial class IdentifierCollectionSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -5,8 +5,10 @@ using System.Text.Json.Serialization;
|
||||
namespace View_by_Distance.Rename.Models;
|
||||
|
||||
public record RenameConfiguration(Shared.Models.MetadataConfiguration MetadataConfiguration,
|
||||
string DefaultMaker,
|
||||
bool ForceNewId,
|
||||
string[] IgnoreExtensions,
|
||||
bool MoveFilesToRoot,
|
||||
string RelativePropertyCollectionFile,
|
||||
bool SkipIdFiles,
|
||||
string[] ValidImageFormatExtensions,
|
||||
string[] ValidVideoFormatExtensions) : Shared.Models.Properties.IRenameConfiguration
|
||||
|
Reference in New Issue
Block a user