removed-person

This commit is contained in:
Mike Phares 2023-08-05 09:35:38 -07:00
parent 9686b93617
commit 9fd34adcc1
104 changed files with 29 additions and 2151 deletions

View File

@ -60,7 +60,7 @@ internal abstract class MapLogic
skipNotSkipCollection[id.Value].Add(wholePercentages.Value);
}
}
if (personContainer.Person is null || personContainer.Key is null || personContainer.Birthdays is null || personContainer.Birthdays.Length == 0)
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Birthdays.Length == 0)
continue;
foreach (PersonBirthday personBirthday in personContainer.Birthdays)
{
@ -513,7 +513,6 @@ internal abstract class MapLogic
{
List<PersonContainer> results = new();
bool check;
Person person;
long personKey;
int? approximateYears = null;
PersonBirthday personBirthday;
@ -541,8 +540,7 @@ internal abstract class MapLogic
if (check)
continue;
personBirthday = IPersonBirthday.GetPersonBirthday(personKey + (oneHour * 2));
person = IPerson.GetPerson(configuration.PersonCharacters.ToArray(), configuration.MappingDefaultName, personKey, personBirthday);
personContainer = new(approximateYears, new PersonBirthday[] { personBirthday }, personDisplayDirectoryAllFiles, configuration.MappingDefaultName, personKey, person);
personContainer = new(approximateYears, new PersonBirthday[] { personBirthday }, personDisplayDirectoryAllFiles, configuration.MappingDefaultName, personKey);
results.Add(personContainer);
if (results.Count > 99)
break;
@ -558,7 +556,7 @@ internal abstract class MapLogic
List<long> personKeys = IPersonContainer.GetPersonKeys(personContainers);
foreach (PersonContainer personContainer in personContainers)
{
if (personContainer.Person is null || personContainer.Key is null || personContainer.Birthdays is null || personContainer.Birthdays.Length == 0)
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Birthdays.Length == 0)
continue;
if (personKeys.Contains(personContainer.Key.Value))
continue;

View File

@ -1,26 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net7.0/win-x64/Person.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

View File

@ -1,41 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Person.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Person.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Person.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -1,29 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Person.Models;
public class AppSettings
{
public string Company { init; get; }
public int MaxDegreeOfParallelism { init; get; }
public string WorkingDirectoryName { init; get; }
[JsonConstructor]
public AppSettings(string company,
int maxDegreeOfParallelism,
string workingDirectoryName)
{
Company = company;
MaxDegreeOfParallelism = maxDegreeOfParallelism;
WorkingDirectoryName = workingDirectoryName;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -1,44 +0,0 @@
using Microsoft.Extensions.Configuration;
using System.Text.Json;
namespace View_by_Distance.Person.Models.Binder;
public class AppSettings
{
#nullable disable
public string Company { get; set; }
public int? MaxDegreeOfParallelism { get; set; }
public string WorkingDirectoryName { get; set; }
#nullable restore
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
private static Models.AppSettings Get(AppSettings? appSettings)
{
Models.AppSettings result;
if (appSettings?.MaxDegreeOfParallelism is null)
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
result = new(
appSettings.Company,
appSettings.MaxDegreeOfParallelism.Value,
appSettings.WorkingDirectoryName
);
return result;
}
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings result;
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
result = Get(appSettings);
return result;
}
}

View File

@ -1,61 +0,0 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
namespace View_by_Distance.Person.Models.Binder;
public class Configuration
{
#nullable disable
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
[Display(Name = "Save Directory"), Required] public string SaveDirectory { get; set; }
#nullable restore
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
private static Models.Configuration Get(Configuration? configuration)
{
Models.Configuration result;
if (configuration is null)
throw new NullReferenceException(nameof(configuration));
if (configuration.IgnoreExtensions is null)
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
if (configuration.PersonBirthdayFormat is null)
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
result = new(
configuration.IgnoreExtensions,
configuration.PersonBirthdayFormat,
configuration.PropertyConfiguration,
configuration.SaveDirectory);
return result;
}
public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, Property.Models.Configuration propertyConfiguration)
{
Models.Configuration result;
Configuration? configuration;
if (isEnvironment is null)
configuration = configurationRoot.Get<Configuration>();
else
{
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
string section = string.Concat(environmentName, ":", nameof(Configuration));
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
configuration = configurationSection.Get<Configuration>();
}
result = Get(configuration);
result.SetAndUpdate(propertyConfiguration);
return result;
}
}

View File

@ -1,41 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Person.Models;
public class Configuration
{
protected Property.Models.Configuration _PropertyConfiguration;
public string[] IgnoreExtensions { init; get; }
public string PersonBirthdayFormat { init; get; }
public string SaveDirectory { init; get; }
public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration;
[JsonConstructor]
public Configuration(
string[] ignoreExtensions,
string personBirthdayFormat,
Property.Models.Configuration propertyConfiguration,
string saveDirectory)
{
IgnoreExtensions = ignoreExtensions;
PersonBirthdayFormat = personBirthdayFormat;
_PropertyConfiguration = propertyConfiguration;
SaveDirectory = saveDirectory;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
public void SetAndUpdate(Property.Models.Configuration configuration)
{
_PropertyConfiguration = configuration;
_PropertyConfiguration.Update();
}
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Person.Models.Stateless;
public static class SerilogExtensionMethods
{
internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
}

View File

@ -1,276 +0,0 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
using Serilog;
using System.Text.Json;
using View_by_Distance.Person.Models;
using View_by_Distance.Shared.Models;
using View_by_Distance.Shared.Models.Stateless.Methods;
namespace View_by_Distance.Person;
public class Person
{
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly IsEnvironment _IsEnvironment;
private readonly Configuration _Configuration;
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
public Person(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, Shared.Models.Methods.IConsole console)
{
if (isSilent)
{ }
if (console is null)
{ }
_AppSettings = appSettings;
_IsEnvironment = isEnvironment;
long ticks = DateTime.Now.Ticks;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
ILogger? log = Log.ForContext<Person>();
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
_PropertyConfiguration = propertyConfiguration;
_Configuration = configuration;
propertyConfiguration.Update();
string? comparePathRoot = Path.GetDirectoryName(configuration.SaveDirectory);
if (comparePathRoot is null || comparePathRoot == propertyConfiguration.RootDirectory)
throw new Exception("Nested isn't allowed!");
if (!Directory.Exists(configuration.SaveDirectory))
_ = Directory.CreateDirectory(configuration.SaveDirectory);
log.Information(propertyConfiguration.RootDirectory);
Verify();
Loop(ticks, log);
}
private void Verify()
{
if (_AppSettings is null)
{ }
if (_IsEnvironment is null)
{ }
if (_Configuration is null)
{ }
if (_ConfigurationRoot is null)
{ }
if (_WorkingDirectory is null)
{ }
if (_PropertyConfiguration is null)
{ }
}
private void Loop(long ticks, ILogger log)
{
Uri uri;
HttpClient httpClient = new();
string fileName;
Task<byte[]> task;
int age;
int hours;
bool alive;
string json;
string? day;
string alias;
string? line;
string? year;
string? month;
ConsoleKey sex;
long personKey;
string? lastName;
string middleName;
string? firstName;
DateTime? dateTime;
string checkDirectory;
PersonName? personName;
DateTime parseDateTime;
ConsoleKey? consoleKey;
string? approximateYears;
string personKeyFormatted;
string personDisplayDirectory;
log.Information($"Ready to create / update a person? [{ticks}]");
for (int y = 0; y < int.MaxValue; y++)
{
personName = null;
log.Information("Press \"Y\" key to continue, \"N\" key exit or close console");
consoleKey = System.Console.ReadKey().Key;
log.Information(". . .");
if (consoleKey is not ConsoleKey.Y and not ConsoleKey.N)
break;
else if (consoleKey is ConsoleKey.N)
break;
firstName = null;
for (int f = 0; f < 5; f++)
{
log.Information("Enter persons first name (minimum length of two characters)");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line) || line.Length < 2)
continue;
firstName = line.Trim();
break;
}
if (firstName is null)
continue;
lastName = null;
for (int f = 0; f < 5; f++)
{
personName = IPerson.GetPersonName(firstName);
if (!string.IsNullOrEmpty(personName.First.Value) && !string.IsNullOrEmpty(personName.Last.Value))
lastName = personName.Last.Value;
else
{
personName = null;
log.Information("Enter persons last name (minimum length of two characters)");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line) || line.Length < 2)
continue;
lastName = line.Trim();
}
break;
}
if (lastName is null)
continue;
if (personName is not null)
middleName = personName.Middle.Value;
else
{
log.Information("Enter persons middle name (press enter if they don't have a middle name)");
line = System.Console.ReadLine();
log.Information(". . .");
middleName = string.IsNullOrEmpty(line) ? string.Empty : line;
}
log.Information("Enter persons alias (press enter if they don't have a alias)");
line = System.Console.ReadLine();
log.Information(". . .");
alias = string.IsNullOrEmpty(line) ? string.Empty : line;
personName ??= new(new(firstName), new(middleName), new(lastName), new(alias));
json = JsonSerializer.Serialize(personName, new JsonSerializerOptions { WriteIndented = true });
log.Information("Is the person \"M\" (Male), \"F\" (Female) or \"U\" (Unknown)");
consoleKey = System.Console.ReadKey().Key;
log.Information(". . .");
if (consoleKey is not ConsoleKey.M and not ConsoleKey.F and not ConsoleKey.U)
continue;
sex = consoleKey.Value;
log.Information("Is the person alive \"Y\" or \"N\"");
consoleKey = System.Console.ReadKey().Key;
log.Information(". . .");
if (consoleKey is not ConsoleKey.Y and not ConsoleKey.N)
continue;
alive = consoleKey == ConsoleKey.Y;
dateTime = null;
approximateYears = null;
for (int f = 0; f < 5; f++)
{
day = null;
year = null;
month = null;
approximateYears = null;
log.Information("Enter persons birthday month (press enter if not known) [MMMM || MMM || MM || M]");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line))
{
log.Information("Enter persons approximate age");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line) || !int.TryParse(line, out _))
continue;
approximateYears = line.Trim();
}
else
{
month = line.Trim();
if (DateTime.TryParse(month, out parseDateTime) && parseDateTime != DateTime.MinValue)
{
month = parseDateTime.Month.ToString();
day = parseDateTime.Day.ToString();
year = parseDateTime.Year.ToString();
}
else
{
log.Information("Enter persons birthday day (press enter if not known)");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line))
{
log.Information("Enter persons approximate age");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line) || !int.TryParse(line, out _))
continue;
approximateYears = line.Trim();
}
else
{
day = line.Trim();
log.Information("Enter persons birthday year (press enter if not known)");
line = System.Console.ReadLine();
log.Information(". . .");
if (!string.IsNullOrEmpty(line))
year = line.Trim();
else
{
log.Information("Enter persons approximate age");
line = System.Console.ReadLine();
log.Information(". . .");
if (string.IsNullOrEmpty(line) || !int.TryParse(line, out _))
continue;
approximateYears = line.Trim();
}
}
}
}
if (month is null || day is null || year is null)
dateTime = null;
else
{
dateTime = IPersonBirthday.GetDate(month, day, year);
if (dateTime is not null)
{
(age, _) = IAge.GetAge(new DateTime(ticks).Ticks, dateTime.Value);
approximateYears = age.ToString();
}
}
if (approximateYears is null && (dateTime is null || dateTime == DateTime.MinValue))
continue;
break;
}
if (approximateYears is null)
continue;
personDisplayDirectory = Path.Combine(_Configuration.SaveDirectory, ticks.ToString(), $"{personName.First.Value} {personName.Last.Value}~{approximateYears}");
if (!Directory.Exists(personDisplayDirectory))
_ = Directory.CreateDirectory(personDisplayDirectory);
log.Information("Enter url to download an image (press enter if none)");
line = System.Console.ReadLine();
log.Information(". . .");
if (!string.IsNullOrEmpty(line))
{
uri = new(line.Trim());
if (uri.HostNameType != UriHostNameType.Dns)
continue;
task = httpClient.GetByteArrayAsync(uri);
fileName = Path.Combine(personDisplayDirectory, Path.GetFileName(uri.LocalPath));
File.WriteAllBytes(fileName, task.Result);
}
if (dateTime is null)
personKeyFormatted = "2";
else
{
hours = IPersonBirthday.GetHour(alive, sex);
personKey = dateTime.Value.AddHours(hours).Ticks;
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey);
}
checkDirectory = Path.Combine(personDisplayDirectory, personKeyFormatted);
log.Information($"Working directory <{checkDirectory}>");
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
_ = IPath.WriteAllText(Path.Combine(checkDirectory, $"{personKeyFormatted}.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true);
log.Information($"Person saved ({personName.First.Value} {personName.Last.Value})");
}
log.Information(". . .");
}
}

View File

@ -1,59 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>7ca5318a-9332-4217-b9d8-cae696629934</UserSecretsId>
</PropertyGroup>
<PropertyGroup>
<PackageId>Phares.View.by.Distance.Person</PackageId>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>7.0.101.1</Version>
<Authors>Mike Phares</Authors>
<Company>Phares</Company>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>Windows</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<DefineConstants>OSX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>Linux</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Property\Property.csproj" />
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,71 +0,0 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
using Serilog;
using System.Diagnostics;
using System.Reflection;
using View_by_Distance.Person.Models;
using View_by_Distance.Shared.Models.Stateless.Methods;
namespace View_by_Distance.Person;
public class Program
{
public static void Secondary(List<string> args)
{
LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
.AddUserSecrets<Program>();
IConfigurationRoot configurationRoot = configurationBuilder.Build();
AppSettings appSettings = Models.Binder.AppSettings.Get(configurationRoot);
if (appSettings.MaxDegreeOfParallelism > Environment.ProcessorCount)
throw new Exception("MaxDegreeOfParallelism must be =< Environment.ProcessorCount!");
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
Log.Logger = loggerConfiguration.CreateLogger();
ILogger log = Log.ForContext<Program>();
int silentIndex = args.IndexOf("s");
if (silentIndex > -1)
args.RemoveAt(silentIndex);
try
{
if (args is null)
throw new Exception("args is null!");
Shared.Models.Console console = new();
_ = new Person(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
}
catch (Exception ex)
{
log.Fatal(string.Concat(ex.Message, Environment.NewLine, ex.StackTrace));
}
finally
{
Log.CloseAndFlush();
}
if (silentIndex > -1)
log.Debug("Done. Bye");
else
{
log.Debug("Done. Press 'Enter' to end");
_ = Console.ReadLine();
}
}
public static void Main(string[] args)
{
if (args is not null)
Secondary(args.ToList());
else
Secondary(new List<string>());
}
}

View File

@ -1,10 +0,0 @@
{
"Logging": {
"LogLevel": {
"Log4netProvider": "Debug"
}
},
"Serilog": {
"MinimumLevel": "Debug"
}
}

View File

@ -1,140 +0,0 @@
{
"Company": "Mike Phares",
"Linux": {
"Configuration": {
"DateGroup": "dd514b88",
"DiffPropertyDirectory": "",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
"MaxImagesInDirectoryForTopLevelFirstPass": 10,
"OutputExtension": ".jpg",
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PersonBirthdayFormat": "yyyy-MM-dd_HH",
"PopulatePropertyId": true,
"PropertiesChangedForProperty": false,
"ResultAllInOne": "_ _ _",
"ResultAllInOneSubdirectoryLength": 2,
"ResultCollection": "[]",
"ResultContent": "()",
"ResultSingleton": "{}",
"RootDirectory": "/srv/samba/share",
"SaveDirectory": "/home/vscode",
"IgnoreExtensions": [
".gif",
".GIF",
".nef",
".NEF",
".pdf",
".PDF"
],
"ValidImageFormatExtensions": [
".bmp",
".BMP",
".gif",
".GIF",
".jpeg",
".JPEG",
".jpg",
".JPG",
".png",
".PNG",
".tiff",
".TIFF",
".tif",
".TIF"
]
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Log4netProvider": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"MaxDegreeOfParallelism": 1,
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File"
],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "Debug",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
}
},
{
"Name": "Console",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "%workingDirectory% - Log/log-.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
"rollingInterval": "Hour"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "Sample"
}
},
"Windows": {
"Configuration": {
"DateGroup": "dd514b88",
"DiffPropertyDirectory": "",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
"MaxImagesInDirectoryForTopLevelFirstPass": 10,
"OutputExtension": ".jpg",
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PersonBirthdayFormat": "yyyy-MM-dd_HH",
"PopulatePropertyId": true,
"PropertiesChangedForProperty": false,
"ResultAllInOne": "_ _ _",
"ResultAllInOneSubdirectoryLength": 2,
"ResultCollection": "[]",
"ResultContent": "()",
"ResultSingleton": "{}",
"RootDirectory": "C:/Tmp/Phares/Compare/Images-dd514b88",
"SaveDirectory": "D:/Tmp",
"IgnoreExtensions": [
".gif",
".GIF",
".nef",
".NEF",
".pdf",
".PDF"
],
"ValidImageFormatExtensions": [
".bmp",
".BMP",
".gif",
".GIF",
".jpeg",
".JPEG",
".jpg",
".JPG",
".png",
".PNG",
".tiff",
".TIFF",
".tif",
".TIF"
]
}
},
"WorkingDirectoryName": "PharesApps"
}

View File

@ -143,7 +143,6 @@ public class F_PhotoPrism
private static void PopulateSubjects(string mappingDefaultName, string personBirthdayFormat, List<string> subjects, StringBuilder stringBuilder, PersonContainer[] personContainers, (MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, float Percent)[] sortedCollection)
{
long? personKey;
string personName;
const int zero = 0;
string personKeyFormatted;
PersonBirthday personBirthday;
@ -151,18 +150,17 @@ public class F_PhotoPrism
{
foreach (PersonContainer personContainer in personContainers)
{
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Person is null || !personContainer.Birthdays.Any())
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
continue;
if (IPerson.IsDefaultName(mappingDefaultName, personContainer.DisplayDirectoryName) || IPerson.IsDefaultName(mappingDefaultName, personContainer.Person))
if (IPerson.IsDefaultName(mappingDefaultName, personContainer.DisplayDirectoryName))
continue;
personBirthday = personContainer.Birthdays[zero];
personKey = personBirthday.Value.Ticks;
personName = personContainer.Person.GetFullName();
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
subjects.Add($"update `subjects` set subj_alias = '{personKeyFormatted}' where subj_name = '{personName}';");
subjects.Add($"update `subjects` set subj_alias = '{personKeyFormatted}' where subj_name = '{personContainer.DisplayDirectoryName}';");
_ = stringBuilder.
Append("update `markers` set subj_src = 'manual', marker_name = '").
Append(personName).
Append(personContainer.DisplayDirectoryName).
Append("' where marker_uid = '").
Append(marker.MarkerUid).
AppendLine("';");

View File

@ -1,6 +1,6 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IOutputResolution : Stateless.Methods.IPerson
public interface IOutputResolution
{
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPerson : Stateless.Methods.IPerson
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonAddress : Stateless.Methods.IPersonAddress
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonAddressCity : Stateless.Methods.IPersonAddressCity
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonAddressState : Stateless.Methods.IPersonAddressState
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonAddressStreet : Stateless.Methods.IPersonAddressStreet
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonAddressZipCode : Stateless.Methods.IPersonAddressZipCode
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonComment : Stateless.Methods.IPersonComment
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonEmail : Stateless.Methods.IPersonEmail
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonId : Stateless.Methods.IPersonId
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonName : Stateless.Methods.IPersonName
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonNameAlias : Stateless.Methods.IPersonNameAlias
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonNameFirst : Stateless.Methods.IPersonNameFirst
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonNameLast : Stateless.Methods.IPersonNameLast
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonNameMiddle : Stateless.Methods.IPersonNameMiddle
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonNumber : Stateless.Methods.IPersonNumber
{
// ...
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IPersonURL : Stateless.Methods.IPersonURL
{
// ...
}

View File

@ -1,71 +0,0 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class Person : Properties.IPerson
{
protected readonly PersonId _Id; // {-_-}SingletonClass
protected readonly PersonBirthday _Birthday; // {-_-}SingletonClass
protected readonly PersonName _Name; // {{_}}JsonValueKindObject
protected readonly List<PersonComment> _Comments; // <{_}>PluralClass
protected readonly List<PersonURL> _URLs; // <{_}>PluralClass
protected readonly List<PersonNumber> _Numbers; // <{_}>PluralClass
protected readonly List<PersonEmail> _Emails; // <{_}>PluralClass
protected readonly List<PersonAddress> _Addresses; // <<_>>JsonValueKindArray
public PersonId Id => _Id; // {-_-}SingletonClass
public PersonBirthday Birthday => _Birthday; // {-_-}SingletonClass
public PersonName Name => _Name; // {{_}}JsonValueKindObject
public List<PersonComment> Comments => _Comments; // <{_}>PluralClass
public List<PersonURL> URLs => _URLs; // <{_}>PluralClass
public List<PersonNumber> Numbers => _Numbers; // <{_}>PluralClass
public List<PersonEmail> Emails => _Emails; // <{_}>PluralClass
public List<PersonAddress> Addresses => _Addresses; // <<_>>JsonValueKindArray
[JsonConstructor]
public Person
(
PersonId id,
PersonBirthday birthday,
PersonName name,
List<PersonComment> comments,
List<PersonURL> uRLs,
List<PersonNumber> numbers,
List<PersonEmail> emails,
List<PersonAddress> addresses
)
{
_Id = id; // {-_-}SingletonClass
_Birthday = birthday; // {-_-}SingletonClass
_Name = name; // {{_}}JsonValueKindObject
_Comments = comments; // <{_}>PluralClass
_URLs = uRLs; // <{_}>PluralClass
_Numbers = numbers; // <{_}>PluralClass
_Emails = emails; // <{_}>PluralClass
_Addresses = addresses; // <<_>>JsonValueKindArray
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
public string GetFullName()
{
StringBuilder result = new();
if (_Name?.First is not null && !string.IsNullOrEmpty(_Name.First.Value))
_ = result.Append(_Name.First.Value);
if (_Name?.Middle is not null && !string.IsNullOrEmpty(_Name.Middle.Value))
_ = result.Append(' ').Append(_Name.Middle.Value);
if (_Name?.Last is not null && !string.IsNullOrEmpty(_Name.Last.Value))
_ = result.Append(' ').Append(_Name.Last.Value);
if (_Name?.Alias is not null && !string.IsNullOrEmpty(_Name.Alias.Value))
_ = result.Append(" (").Append(_Name.Alias.Value).Append(')');
return result.ToString();
}
}

View File

@ -1,40 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonAddress : Properties.IPersonAddress
{
protected readonly PersonAddressStreet _Street; // {-_-}SingletonClass
protected readonly PersonAddressCity _City; // {-_-}SingletonClass
protected readonly PersonAddressState _State; // {-_-}SingletonClass
protected readonly PersonAddressZipCode _ZipCode; // {-_-}SingletonClass
public PersonAddressStreet Street => _Street; // {-_-}SingletonClass
public PersonAddressCity City => _City; // {-_-}SingletonClass
public PersonAddressState State => _State; // {-_-}SingletonClass
public PersonAddressZipCode ZipCode => _ZipCode; // {-_-}SingletonClass
[JsonConstructor]
public PersonAddress
(
PersonAddressStreet street,
PersonAddressCity city,
PersonAddressState state,
PersonAddressZipCode zipCode
)
{
_Street = street; // {-_-}SingletonClass
_City = city; // {-_-}SingletonClass
_State = state; // {-_-}SingletonClass
_ZipCode = zipCode; // {-_-}SingletonClass
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonAddressCity : Properties.IPersonAddressCity
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonAddressCity
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonAddressState : Properties.IPersonAddressState
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonAddressState
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonAddressStreet : Properties.IPersonAddressStreet
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonAddressStreet
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonAddressZipCode : Properties.IPersonAddressZipCode
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonAddressZipCode
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonComment : Properties.IPersonComment
{
protected readonly string _Value; // <{1}>PluralValue
public string Value => _Value; // <{1}>PluralValue
[JsonConstructor]
public PersonComment
(
string value
) => _Value = value; // <{1}>PluralValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -12,40 +12,38 @@ public class PersonContainer : Properties.IPersonContainer
public string DisplayDirectoryName { init; get; }
public long? Key { init; get; }
public bool? KeyIsMaxBirthday { init; get; }
public Person? Person { init; get; }
public PersonDirectory? PersonDirectory { init; get; }
[JsonConstructor]
public PersonContainer(int? approximateYears, PersonBirthday[]? birthdays, string[] displayDirectoryAllFiles, string displayDirectoryName, long? key, Person? person, PersonDirectory? personDirectory)
public PersonContainer(int? approximateYears, PersonBirthday[]? birthdays, string[] displayDirectoryAllFiles, string displayDirectoryName, long? key, PersonDirectory? personDirectory)
{
ApproximateYears = approximateYears;
Birthdays = birthdays;
DisplayDirectoryAllFiles = displayDirectoryAllFiles;
DisplayDirectoryName = displayDirectoryName;
Key = key;
Person = person;
PersonDirectory = personDirectory;
KeyIsMaxBirthday = birthdays is null || key is null ? null : key.Value == birthdays.First().Value.Ticks;
}
public PersonContainer(char[] personCharacters, PersonBirthday birthday, string displayDirectoryName, PersonDirectory personDirectory) :
this(Stateless.Methods.IAge.GetApproximateYears(personCharacters, displayDirectoryName), new PersonBirthday[] { birthday }, Array.Empty<string>(), displayDirectoryName, birthday.Value.Ticks, Stateless.Methods.IPerson.GetPerson(personCharacters, displayDirectoryName, birthday.Value.Ticks, birthday), personDirectory)
this(Stateless.Methods.IAge.GetApproximateYears(personCharacters, displayDirectoryName), new PersonBirthday[] { birthday }, Array.Empty<string>(), displayDirectoryName, birthday.Value.Ticks, personDirectory)
{ }
public PersonContainer(int? approximateYears, PersonBirthday birthdays, string displayDirectoryName, long key) :
this(approximateYears, new PersonBirthday[] { birthdays }, Array.Empty<string>(), displayDirectoryName, key, null, null)
this(approximateYears, new PersonBirthday[] { birthdays }, Array.Empty<string>(), displayDirectoryName, key, null)
{ }
public PersonContainer(int? approximateYears, PersonBirthday birthdays, PersonDirectory? personDirectory, string displayDirectoryName, long key) :
this(approximateYears, new PersonBirthday[] { birthdays }, Array.Empty<string>(), displayDirectoryName, key, null, personDirectory)
this(approximateYears, new PersonBirthday[] { birthdays }, Array.Empty<string>(), displayDirectoryName, key, personDirectory)
{ }
public PersonContainer(int? approximateYears, string[] displayDirectoryAllFiles, string displayDirectoryName, PersonDirectory? personDirectory) :
this(approximateYears, null, displayDirectoryAllFiles, displayDirectoryName, null, null, personDirectory)
this(approximateYears, null, displayDirectoryAllFiles, displayDirectoryName, null, personDirectory)
{ }
public PersonContainer(int? approximateYears, PersonBirthday[]? birthdays, string[] displayDirectoryAllFiles, string displayDirectoryName, long? key, Person? person) :
this(approximateYears, birthdays, displayDirectoryAllFiles, displayDirectoryName, key, person, null)
public PersonContainer(int? approximateYears, PersonBirthday[]? birthdays, string[] displayDirectoryAllFiles, string displayDirectoryName, long? key) :
this(approximateYears, birthdays, displayDirectoryAllFiles, displayDirectoryName, key, null)
{ }
public override string ToString()

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonEmail : Properties.IPersonEmail
{
protected readonly string _Value; // <{1}>PluralValue
public string Value => _Value; // <{1}>PluralValue
[JsonConstructor]
public PersonEmail
(
string value
) => _Value = value; // <{1}>PluralValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonId : Properties.IPersonId
{
protected readonly long _Value; // {{1}}SingletonValue
public long Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonId
(
long value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,37 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonImport
{
public DateTime _Key;
public string _Name;
public string _MergeName;
public string _OldName;
public string _Comment;
public DateTime Key => _Key;
public string Name => _Name;
public string MergeName => _MergeName;
public string OldName => _OldName;
public string Comment => _Comment;
[JsonConstructor]
public PersonImport(DateTime key, string name, string mergeName, string oldName, string comment)
{
_Key = key;
_Name = name;
_MergeName = mergeName;
_OldName = oldName;
_Comment = comment;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -1,40 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonName : Properties.IPersonName
{
protected readonly PersonNameFirst _First; // {-_-}SingletonClass
protected readonly PersonNameMiddle _Middle; // {-_-}SingletonClass
protected readonly PersonNameLast _Last; // {-_-}SingletonClass
protected readonly PersonNameAlias _Alias; // {-_-}SingletonClass
public PersonNameFirst First => _First; // {-_-}SingletonClass
public PersonNameMiddle Middle => _Middle; // {-_-}SingletonClass
public PersonNameLast Last => _Last; // {-_-}SingletonClass
public PersonNameAlias Alias => _Alias; // {-_-}SingletonClass
[JsonConstructor]
public PersonName
(
PersonNameFirst first,
PersonNameMiddle middle,
PersonNameLast last,
PersonNameAlias alias
)
{
_First = first; // {-_-}SingletonClass
_Middle = middle; // {-_-}SingletonClass
_Last = last; // {-_-}SingletonClass
_Alias = alias; // {-_-}SingletonClass
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonNameAlias : Properties.IPersonNameAlias
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonNameAlias
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonNameFirst : Properties.IPersonNameFirst
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonNameFirst
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonNameLast : Properties.IPersonNameLast
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonNameLast
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonNameMiddle : Properties.IPersonNameMiddle
{
protected readonly string _Value; // {{1}}SingletonValue
public string Value => _Value; // {{1}}SingletonValue
[JsonConstructor]
public PersonNameMiddle
(
string value
) => _Value = value; // {{1}}SingletonValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonNumber : Properties.IPersonNumber
{
protected readonly string _Value; // <{1}>PluralValue
public string Value => _Value; // <{1}>PluralValue
[JsonConstructor]
public PersonNumber
(
string value
) => _Value = value; // <{1}>PluralValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,25 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public class PersonURL : Properties.IPersonURL
{
protected readonly string _Value; // <{1}>PluralValue
public string Value => _Value; // <{1}>PluralValue
[JsonConstructor]
public PersonURL
(
string value
) => _Value = value; // <{1}>PluralValue
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
} // ...
}

View File

@ -1,15 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPerson
{
public PersonId Id { get; } //long
public PersonBirthday Birthday { get; } //DateTime
public PersonName Name { get; } //JsonValueKind.Object
public List<PersonComment> Comments { get; } //string
public List<PersonURL> URLs { get; } //string
public List<PersonNumber> Numbers { get; } //string
public List<PersonEmail> Emails { get; } //string
public List<PersonAddress> Addresses { get; } //JsonValueKind.Array
} // ...

View File

@ -1,11 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonAddress
{
public PersonAddressStreet Street { get; } //string
public PersonAddressCity City { get; } //string
public PersonAddressState State { get; } //string
public PersonAddressZipCode ZipCode { get; } //string
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonAddressCity
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonAddressState
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonAddressStreet
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonAddressZipCode
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonComment
{
public string Value { get; }
} // ...

View File

@ -9,7 +9,6 @@ public interface IPersonContainer
public string DisplayDirectoryName { init; get; }
public long? Key { init; get; }
public bool? KeyIsMaxBirthday { init; get; }
public Person? Person { init; get; }
public PersonDirectory? PersonDirectory { init; get; }
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonEmail
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonId
{
public long Value { get; }
} // ...

View File

@ -1,11 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonName
{
public PersonNameFirst First { get; } //string
public PersonNameMiddle Middle { get; } //string
public PersonNameLast Last { get; } //string
public PersonNameAlias Alias { get; } //string
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonNameAlias
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonNameFirst
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonNameLast
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonNameMiddle
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonNumber
{
public string Value { get; }
} // ...

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Properties;
public interface IPersonURL
{
public string Value { get; }
} // ...

View File

@ -5,11 +5,6 @@ public interface IPerson
// ...
Models.PersonName TestStatic_GetPersonName(string name) =>
GetPersonName(name);
static Models.PersonName GetPersonName(string name) =>
PersonName.GetPersonName(name);
static (char, char, char) GetPersonHour(string personDisplayDirectoryName, int hour) =>
hour == 0 ? new('U', 'U', 'U') :
hour == 1 ? new('U', 'U', 'U') :
@ -47,24 +42,4 @@ public interface IPerson
static bool IsDefaultName(string mappingDefaultName, string value) =>
value == mappingDefaultName || (value.Length > 1 && value[0] == 'X' && value[1] == ']');
bool TestStatic_IsDefaultName(string mappingDefaultName, Models.Person person) =>
IsDefaultName(mappingDefaultName, person);
static bool IsDefaultName(string mappingDefaultName, Models.Person person) =>
IsDefaultName(mappingDefaultName, person.Name.Alias is null ? string.Empty : person.Name.Alias.Value);
string TestStatic_GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
GetFileFullName(storage, personBirthdayFormat, person);
static string GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
IPersonBirthday.GetFileFullName(storage, personBirthdayFormat, person.Birthday);
Models.Person TestStatic_GetPerson(char[] personCharacters, string personDisplayDirectoryName, long personKey, Models.PersonBirthday personBirthday) =>
GetPerson(personCharacters, personDisplayDirectoryName, personKey, personBirthday);
static Models.Person GetPerson(char[] personCharacters, string personDisplayDirectoryName, long personKey, Models.PersonBirthday personBirthday) =>
Person.GetPerson(personCharacters, personDisplayDirectoryName, Array.Empty<string>(), personKey, personBirthday);
Models.Person TestStatic_GetPerson(char[] personCharacters, string personDisplayDirectoryName, string[] personDisplayDirectoryAllFiles, long personKey) =>
GetPerson(personCharacters, personDisplayDirectoryName, personDisplayDirectoryAllFiles, personKey);
static Models.Person GetPerson(char[] personCharacters, string personDisplayDirectoryName, string[] personDisplayDirectoryAllFiles, long personKey) =>
Person.GetPerson(personCharacters, personDisplayDirectoryName, personDisplayDirectoryAllFiles, personKey, IPersonBirthday.GetPersonBirthday(personKey));
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonAddress
{
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonAddressCity
{
string TestStatic_GetDefaultValue() => PersonAddressCity.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonAddressCity.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonAddressState
{
string TestStatic_GetDefaultValue() => PersonAddressState.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonAddressState.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonAddressStreet
{
string TestStatic_GetDefaultValue() => PersonAddressStreet.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonAddressStreet.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonAddressZipCode
{
string TestStatic_GetDefaultValue() => PersonAddressZipCode.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonAddressZipCode.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -125,9 +125,9 @@ public interface IPersonBirthday
static DateTime? GetDateTime(string personBirthdayFormat, string personKeyFormatted) =>
DateTime.TryParseExact(GetDateTime(personKeyFormatted), personBirthdayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null;
List<(string, Models.PersonBirthday)> TestStatic_GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory, string personDisplayDirectoryName) =>
GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectory, personDisplayDirectoryName);
static List<(string, Models.PersonBirthday)> GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory, string personDisplayDirectoryName) =>
PersonBirthday.GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectory, personDisplayDirectoryName);
List<(string, Models.PersonBirthday)> TestStatic_GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectoryName) =>
GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectoryName);
static List<(string, Models.PersonBirthday)> GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectoryName) =>
PersonBirthday.GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectoryName);
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonComment
{
string TestStatic_GetDefaultValue() => PersonComment.GetDefaultValue(); // <{1}>PluralValue
static string GetDefaultValue() => PersonComment.GetDefaultValue(); // <{1}>PluralValue
// ...
}

View File

@ -1,5 +1,3 @@
using System.Collections.ObjectModel;
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonContainer
@ -17,19 +15,9 @@ public interface IPersonContainer
static List<Models.PersonContainer> GetPersonContainers(Properties.IStorage storage, string personBirthdayFormat, char[] personCharacters, string facesFileNameExtension) =>
PersonContainer.GetPersonContainers(storage, personBirthdayFormat, personCharacters, facesFileNameExtension);
List<(long?, string)> TestStatic_GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer) =>
GetDisplay(personBirthdayFormat, personContainer);
static List<(long?, string)> GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer) =>
PersonContainer.GetDisplay(personBirthdayFormat, personContainer);
string? TestStatic_VerifyAge(char numberSign, string personDisplayDirectory, string? minusOne, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection) =>
VerifyAge(numberSign, personDisplayDirectory, minusOne, personDisplayDirectoryName, approximateYears, collection);
static string? VerifyAge(char numberSign, string personDisplayDirectory, string? minusOne, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection) =>
PersonContainer.VerifyAge(numberSign, personDisplayDirectory, minusOne, personDisplayDirectoryName, approximateYears, collection);
ReadOnlyDictionary<string, string> TestStatic_GetPersonKeyFormattedToPersonFullName(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers) =>
GetPersonKeyFormattedToPersonFullName(personBirthdayFormat, personContainers);
static ReadOnlyDictionary<string, string> GetPersonKeyFormattedToPersonFullName(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers) =>
PersonContainer.GetPersonKeyFormattedToPersonFullName(personBirthdayFormat, personContainers);
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonEmail
{
string TestStatic_GetDefaultValue() => PersonEmail.GetDefaultValue(); // <{1}>PluralValue
static string GetDefaultValue() => PersonEmail.GetDefaultValue(); // <{1}>PluralValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonId
{
long TestStatic_GetDefaultValue() => PersonId.GetDefaultValue(); // {{1}}SingletonValue
static long GetDefaultValue() => PersonId.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,13 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonName
{
// ...
string TestStatic_GetFullName(Models.PersonName personName) =>
GetFullName(personName);
static string GetFullName(Models.PersonName personName) =>
PersonName.GetFullName(personName);
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonNameAlias
{
string TestStatic_GetDefaultValue() => PersonNameAlias.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonNameAlias.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonNameFirst
{
string TestStatic_GetDefaultValue() => PersonNameFirst.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonNameFirst.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonNameLast
{
string TestStatic_GetDefaultValue() => PersonNameLast.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonNameLast.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonNameMiddle
{
string TestStatic_GetDefaultValue() => PersonNameMiddle.GetDefaultValue(); // {{1}}SingletonValue
static string GetDefaultValue() => PersonNameMiddle.GetDefaultValue(); // {{1}}SingletonValue
// ...
}

View File

@ -1,12 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonNumber
{
string TestStatic_GetDefaultValue() => PersonNumber.GetDefaultValue(); // <{1}>PluralValue
static string GetDefaultValue() => PersonNumber.GetDefaultValue(); // <{1}>PluralValue
// ...
}

View File

@ -1,13 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface IPersonURL
{
string TestStatic_GetDefaultValue() =>
GetDefaultValue(); // <{1}>PluralValue
static string GetDefaultValue() =>
PersonURL.GetDefaultValue(); // <{1}>PluralValue
// ...
}

View File

@ -1,48 +0,0 @@
using System.Text.Json;
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class Person
{
// ...
internal static (Models.PersonBirthday?, string) Get(string personBirthdayFormat, string personDisplayDirectory, string personKeyDirectory, DateTime birthday)
{
Models.PersonBirthday? personBirthday = new(birthday);
string personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
string convertedPersonKeyDirectory = Path.Combine(personDisplayDirectory, personKeyFormatted);
if (!Directory.Exists(convertedPersonKeyDirectory))
Directory.Move(personKeyDirectory, convertedPersonKeyDirectory);
return new(personBirthday, personKeyFormatted);
}
internal static Models.Person GetPerson(char[] personCharacters, string personDisplayDirectoryName, string[] personDisplayDirectoryAllFiles, long personKey, Models.PersonBirthday personBirthday)
{
Models.Person result;
string[] matches;
List<Models.PersonURL> urls = new();
Models.PersonId id = new(personKey);
List<Models.PersonEmail> emails = new();
List<Models.PersonNumber> numbers = new();
List<Models.PersonComment> comments = new();
List<Models.PersonAddress> addresses = new();
string checkFileName = $"{personDisplayDirectoryName.First()}.json";
string nameWithoutApproximateYears = personDisplayDirectoryName.Split(personCharacters).First();
matches = (from l in personDisplayDirectoryAllFiles where Path.GetFileName(l) == checkFileName select l).ToArray();
Models.PersonName? name;
if (!matches.Any())
name = PersonName.GetPersonName(nameWithoutApproximateYears);
else
{
string json = File.ReadAllText(matches.First());
name = JsonSerializer.Deserialize<Models.PersonName>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
name ??= PersonName.GetPersonName(nameWithoutApproximateYears);
if (name.Last is null || string.IsNullOrEmpty(name.Last.Value))
name = PersonName.GetPersonName(nameWithoutApproximateYears);
}
result = new(id, personBirthday, name, comments, urls, numbers, emails, addresses);
return result;
}
}

View File

@ -1,8 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonAddress
{
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonAddressCity
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonAddressState
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonAddressStreet
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonAddressZipCode
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -87,7 +87,7 @@ internal abstract class PersonBirthday
return result;
}
internal static List<(string, Models.PersonBirthday)> GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory, string personDisplayDirectoryName)
internal static List<(string, Models.PersonBirthday)> GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectoryName)
{
List<(string, Models.PersonBirthday)> results = new();
string personKeyFormatted;
@ -98,7 +98,8 @@ internal abstract class PersonBirthday
if (!DateTime.TryParseExact(personKeyFormatted, "MM.dd.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime birthday))
personBirthday = IPersonBirthday.GetPersonBirthday(personBirthdayFormat, personKeyFormatted);
else
(personBirthday, personKeyFormatted) = Person.Get(personBirthdayFormat, personDisplayDirectory, personKeyDirectory, birthday);
// (personBirthday, personKeyFormatted) = Person.Get(personBirthdayFormat, personDisplayDirectory, personKeyDirectory, birthday);
continue;
if (personBirthday is null)
continue;
if (!IPersonBirthday.IsCounterPersonBirthday(personBirthday) && ((!personKeyDirectory.Contains('#') && (personDisplayDirectoryName.Contains('~') || personDisplayDirectoryName.Contains('#'))) || (personKeyDirectory.Contains('#') && !personDisplayDirectoryName.Contains('#'))))

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonComment
{
internal static string GetDefaultValue() => string.Empty; // <{1}>PluralValue
// ...
}

View File

@ -1,5 +1,3 @@
using System.Collections.ObjectModel;
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonContainer
@ -92,13 +90,12 @@ internal abstract class PersonContainer
return results;
}
private static List<Models.PersonContainer> GetPersonContainersCollections(string facesFileNameExtension, char[] personCharacters, PersonDirectory personDirectory, char numberSign, string personDisplayDirectory, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection)
private static List<Models.PersonContainer> GetPersonContainersCollections(string facesFileNameExtension, PersonDirectory personDirectory, char numberSign, string personDisplayDirectory, string personDisplayDirectoryName, int? approximateYears, List<(string PersonKeyFormatted, Models.PersonBirthday PersonBirthday)> collection)
{
List<Models.PersonContainer> results = new();
long personKey;
string[] files;
const int zero = 0;
Models.Person person;
string personKeyDirectory;
Models.PersonContainer personContainer;
Models.PersonBirthday[] orderedPersonBirthdays;
@ -119,8 +116,7 @@ internal abstract class PersonContainer
if (!files.Any())
continue;
personDisplayDirectoryAllFiles.AddRange(files.Where(l => l.EndsWith(".rel")));
person = IPerson.GetPerson(personCharacters, personDisplayDirectoryName, personDisplayDirectoryAllFiles.ToArray(), personKey);
personContainer = new(approximateYears, orderedPersonBirthdays, personDisplayDirectoryAllFiles.ToArray(), personDisplayDirectoryName, personKey, person, personDirectory);
personContainer = new(approximateYears, orderedPersonBirthdays, personDisplayDirectoryAllFiles.ToArray(), personDisplayDirectoryName, personKey, personDirectory);
results.Add(personContainer);
}
return results;
@ -177,7 +173,7 @@ internal abstract class PersonContainer
continue;
approximateYears = Age.GetApproximateYears(personCharacters, personDisplayDirectoryName);
personKeyDirectories = Directory.GetDirectories(personDisplayDirectory, "*", SearchOption.TopDirectoryOnly);
collection = PersonBirthday.GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectory, personDisplayDirectoryName);
collection = PersonBirthday.GetPersonBirthdays(personBirthdayFormat, personKeyDirectories, personDisplayDirectoryName);
if (personDisplayDirectoryName.Contains('^'))
{
minusOne = Path.GetDirectoryName(personDisplayDirectory);
@ -189,7 +185,7 @@ internal abstract class PersonContainer
continue;
if (collection.Count > 0)
{
personContainers = GetPersonContainersCollections(facesFileNameExtension, personCharacters, personDirectory, numberSign, personDisplayDirectory, personDisplayDirectoryName, approximateYears, collection);
personContainers = GetPersonContainersCollections(facesFileNameExtension, personDirectory, numberSign, personDisplayDirectory, personDisplayDirectoryName, approximateYears, collection);
results.AddRange(personContainers);
}
else
@ -264,7 +260,7 @@ internal abstract class PersonContainer
groupDirectoryName = Path.GetFileName(groupDirectory);
if (personCharacters[i] != groupDirectoryName.First())
continue;
(changes, collection) = GetPersonContainersInnerGroups( personBirthdayFormat, facesFileNameExtension, personCharacters, groupDirectory, groupDirectoryName);
(changes, collection) = GetPersonContainersInnerGroups(personBirthdayFormat, facesFileNameExtension, personCharacters, groupDirectory, groupDirectoryName);
allChanges.AddRange(changes);
personContainers.AddRange(collection);
}
@ -296,31 +292,13 @@ internal abstract class PersonContainer
return results;
}
internal static List<(long?, string)> GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer)
{
List<(long?, string)> results = new();
string personKeyFormatted;
Models.PersonContainer pc = personContainer;
if (pc.Person is null || pc.Key is null || pc.Birthdays is null || !pc.Birthdays.Any())
results.Add(new(pc.Key, string.Concat('\t', pc.Key, '\t', pc.ApproximateYears, '\t', pc.DisplayDirectoryName)));
else
{
foreach (Models.PersonBirthday personBirthday in pc.Birthdays)
{
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
results.Add(new(pc.Key, string.Concat(personKeyFormatted, '\t', pc.Key, '\t', pc.ApproximateYears, '\t', pc.DisplayDirectoryName)));
}
}
return results;
}
internal static List<long> GetPersonKeys(IEnumerable<Models.PersonContainer> personContainers)
{
List<long> results = new();
long personKey;
foreach (Models.PersonContainer personContainer in personContainers)
{
if (personContainer.Person is null || personContainer.Key is null || personContainer.Birthdays is null || personContainer.Birthdays.Length == 0)
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Birthdays.Length == 0)
continue;
foreach (Models.PersonBirthday personBirthday in personContainer.Birthdays)
{
@ -331,24 +309,4 @@ internal abstract class PersonContainer
return results;
}
internal static ReadOnlyDictionary<string, string> GetPersonKeyFormattedToPersonFullName(string personBirthdayFormat, ReadOnlyCollection<Models.PersonContainer> personContainers)
{
Dictionary<string, string> results = new();
string? value;
string personFullName;
string personKeyFormatted;
foreach (Models.PersonContainer personContainer in personContainers)
{
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Person is null || personContainer.PersonDirectory is null || personContainer.Birthdays.Length == 0)
continue;
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personContainer.Key.Value);
personFullName = PersonName.GetFullName(personContainer.Person.Name);
if (!results.TryGetValue(personKeyFormatted, out value))
results.Add(personKeyFormatted, personFullName);
else if (value != personFullName)
throw new NotSupportedException();
}
return new(results);
}
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonEmail
{
internal static string GetDefaultValue() => string.Empty; // <{1}>PluralValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonId
{
internal static long GetDefaultValue() => long.MinValue; // {{1}}SingletonValue
// ...
}

View File

@ -1,81 +0,0 @@
using System.Text;
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonName
{
// ...
internal static Models.PersonName GetPersonName(string name)
{
Models.PersonName result;
Models.PersonNameLast personNameLast;
Models.PersonNameAlias personNameAlias;
Models.PersonNameFirst personNameFirst;
Models.PersonNameMiddle personNameMiddle;
string[] segments = name.Split(' ');
if (segments.Length == 1)
{
personNameFirst = new(string.Empty);
personNameLast = new(string.Empty);
personNameMiddle = new(string.Empty);
personNameAlias = new(segments[0]);
}
else if (segments.Length == 2)
{
personNameFirst = new(segments[0]);
personNameLast = new(segments[1]);
personNameMiddle = new(string.Empty);
personNameAlias = new(string.Empty);
}
else if (segments.Length == 3 && segments[2] is "Jr." or "Jr" or "Sr")
{
personNameFirst = new(segments[0]);
personNameLast = new(segments[1]);
personNameMiddle = new(string.Empty);
personNameAlias = new(string.Join(' ', segments));
}
else
{
string[] comment = name.Split(new string[] { " (" }, StringSplitOptions.None);
if (comment.Length == 1)
{
personNameFirst = new(segments[0]);
personNameLast = new(segments[^1]);
personNameMiddle = new(string.Empty);
personNameAlias = new(string.Join(' ', segments));
}
else
{
segments = comment[0].Split(' ');
personNameFirst = new(segments[0]);
personNameLast = new(segments[^1]);
personNameMiddle = new(string.Empty);
personNameAlias = new(string.Concat(string.Join(' ', segments), " (", comment[1]));
}
}
result = new(personNameFirst, personNameMiddle, personNameLast, personNameAlias);
return result;
}
internal static string GetFullName(Models.PersonName personName)
{
StringBuilder result = new();
if (personName.First is not null && !string.IsNullOrEmpty(personName.First.Value))
_ = result.Append(personName.First.Value);
if (personName.Middle is not null && !string.IsNullOrEmpty(personName.Middle.Value))
_ = result.Append(' ').Append(personName.Middle.Value);
if (personName.Last is not null && !string.IsNullOrEmpty(personName.Last.Value))
_ = result.Append(' ').Append(personName.Last.Value);
if (personName.Alias is not null && !string.IsNullOrEmpty(personName.Alias.Value))
{
if (personName.Alias.Value.Contains(" Jr"))
_ = result.Append(" Jr");
else if (personName.Alias.Value.Contains(" Sr"))
_ = result.Append(" Sr");
}
return result.ToString();
}
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonNameAlias
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonNameFirst
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonNameLast
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

View File

@ -1,10 +0,0 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class PersonNameMiddle
{
internal static string GetDefaultValue() => string.Empty; // {{1}}SingletonValue
// ...
}

Some files were not shown because too many files have changed in this diff Show More