Use shared before local
This commit is contained in:
parent
d3794bf9cc
commit
5c3a151cd3
@ -68,23 +68,22 @@ public class Person
|
||||
string fileName;
|
||||
Task<byte[]> task;
|
||||
int age;
|
||||
int hours;
|
||||
bool alive;
|
||||
string json;
|
||||
string code;
|
||||
string? day;
|
||||
string alias;
|
||||
string? line;
|
||||
string? year;
|
||||
string? month;
|
||||
bool deceased;
|
||||
ConsoleKey sex;
|
||||
long personKey;
|
||||
string? lastName;
|
||||
string[] segments;
|
||||
string middleName;
|
||||
string? firstName;
|
||||
DateTime? dateTime;
|
||||
PersonName personName;
|
||||
string checkDirectory;
|
||||
PersonName? personName;
|
||||
DateTime parseDateTime;
|
||||
ConsoleKey? consoleKey;
|
||||
string? approximateYears;
|
||||
@ -93,6 +92,7 @@ public class Person
|
||||
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(". . .");
|
||||
@ -116,11 +116,12 @@ public class Person
|
||||
lastName = null;
|
||||
for (int f = 0; f < 5; f++)
|
||||
{
|
||||
segments = firstName.Split(' ');
|
||||
if (segments.Length > 1)
|
||||
lastName = segments[^1];
|
||||
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(". . .");
|
||||
@ -132,9 +133,8 @@ public class Person
|
||||
}
|
||||
if (lastName is null)
|
||||
continue;
|
||||
segments = firstName.Split(' ');
|
||||
if (segments.Length > 2)
|
||||
middleName = segments[1];
|
||||
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)");
|
||||
@ -146,7 +146,7 @@ public class Person
|
||||
line = System.Console.ReadLine();
|
||||
log.Information(". . .");
|
||||
alias = string.IsNullOrEmpty(line) ? string.Empty : line;
|
||||
personName = new(new(firstName), new(middleName), new(lastName), new(alias));
|
||||
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;
|
||||
@ -154,12 +154,12 @@ public class Person
|
||||
if (consoleKey is not ConsoleKey.M and not ConsoleKey.F and not ConsoleKey.U)
|
||||
continue;
|
||||
sex = consoleKey.Value;
|
||||
log.Information("Is the person deceased \"Y\" or \"N\"");
|
||||
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;
|
||||
deceased = consoleKey == ConsoleKey.Y;
|
||||
alive = consoleKey == ConsoleKey.Y;
|
||||
dateTime = null;
|
||||
approximateYears = null;
|
||||
for (int f = 0; f < 5; f++)
|
||||
@ -259,12 +259,9 @@ public class Person
|
||||
personKeyFormatted = "2";
|
||||
else
|
||||
{
|
||||
personKey = dateTime.Value.Ticks;
|
||||
if (deceased)
|
||||
code = sex is ConsoleKey.M ? "05" : sex is ConsoleKey.F ? "04" : sex is ConsoleKey.U ? "02" : throw new NotImplementedException();
|
||||
else
|
||||
code = sex is ConsoleKey.M ? "15" : sex is ConsoleKey.F ? "14" : sex is ConsoleKey.U ? "03" : throw new NotImplementedException();
|
||||
personKeyFormatted = $"{IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey)[..^2]}{code}";
|
||||
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}>");
|
||||
|
@ -5,6 +5,11 @@ public interface IPerson
|
||||
|
||||
// ...
|
||||
|
||||
Models.PersonName TestStatic_GetPersonName(string name) =>
|
||||
GetPersonName(name);
|
||||
static Models.PersonName GetPersonName(string name) =>
|
||||
PersonName.Create(name);
|
||||
|
||||
bool TestStatic_IsDefaultName(string mappingDefaultName, string value) =>
|
||||
IsDefaultName(mappingDefaultName, value);
|
||||
static bool IsDefaultName(string mappingDefaultName, string value) =>
|
||||
|
@ -23,6 +23,16 @@ public interface IPersonBirthday
|
||||
static double? GetAge(Models.PersonBirthday birthday) =>
|
||||
PersonBirthday.GetAge(birthday);
|
||||
|
||||
int TestStatic_GetHour(bool alive, char sex) =>
|
||||
GetHour(alive, sex);
|
||||
static int GetHour(bool alive, char sex) =>
|
||||
alive ? sex is 'M' ? 5 : sex is 'F' ? 4 : sex is 'U' ? 2 : throw new NotImplementedException() : sex is 'M' ? 15 : sex is 'F' ? 14 : sex is 'U' ? 3 : throw new NotImplementedException();
|
||||
|
||||
int TestStatic_GetHour(bool alive, ConsoleKey consoleKey) =>
|
||||
GetHour(alive, consoleKey);
|
||||
static int GetHour(bool alive, ConsoleKey consoleKey) =>
|
||||
GetHour(alive, consoleKey.ToString()[0]);
|
||||
|
||||
Models.PersonBirthday TestStatic_GetPersonBirthday(long ticks) =>
|
||||
new(new(ticks));
|
||||
static Models.PersonBirthday GetPersonBirthday(long ticks) =>
|
||||
|
@ -166,11 +166,8 @@ internal abstract class Person
|
||||
sexLine = "1 SEX U";
|
||||
else
|
||||
{
|
||||
string code;
|
||||
if (deathLine is null or not "1 DEAT Y")
|
||||
code = sexLine[6] is 'M' ? "05" : sexLine[6] is 'F' ? "04" : sexLine[6] is 'U' ? "02" : throw new NotImplementedException();
|
||||
else
|
||||
code = sexLine[6] is 'M' ? "15" : sexLine[6] is 'F' ? "14" : sexLine[6] is 'U' ? "03" : throw new NotImplementedException();
|
||||
int hours = IPersonBirthday.GetHour(deathLine is null or not "1 DEAT Y", sexLine[6]);
|
||||
string code = hours.ToString("00");
|
||||
if (directory.EndsWith("00"))
|
||||
directory = string.Concat(directory[..^2], code);
|
||||
else if (directory.EndsWith("01"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user