Use shared before local
This commit is contained in:
parent
d3794bf9cc
commit
5c3a151cd3
@ -68,23 +68,22 @@ public class Person
|
|||||||
string fileName;
|
string fileName;
|
||||||
Task<byte[]> task;
|
Task<byte[]> task;
|
||||||
int age;
|
int age;
|
||||||
|
int hours;
|
||||||
|
bool alive;
|
||||||
string json;
|
string json;
|
||||||
string code;
|
|
||||||
string? day;
|
string? day;
|
||||||
string alias;
|
string alias;
|
||||||
string? line;
|
string? line;
|
||||||
string? year;
|
string? year;
|
||||||
string? month;
|
string? month;
|
||||||
bool deceased;
|
|
||||||
ConsoleKey sex;
|
ConsoleKey sex;
|
||||||
long personKey;
|
long personKey;
|
||||||
string? lastName;
|
string? lastName;
|
||||||
string[] segments;
|
|
||||||
string middleName;
|
string middleName;
|
||||||
string? firstName;
|
string? firstName;
|
||||||
DateTime? dateTime;
|
DateTime? dateTime;
|
||||||
PersonName personName;
|
|
||||||
string checkDirectory;
|
string checkDirectory;
|
||||||
|
PersonName? personName;
|
||||||
DateTime parseDateTime;
|
DateTime parseDateTime;
|
||||||
ConsoleKey? consoleKey;
|
ConsoleKey? consoleKey;
|
||||||
string? approximateYears;
|
string? approximateYears;
|
||||||
@ -93,6 +92,7 @@ public class Person
|
|||||||
log.Information($"Ready to create / update a person? [{ticks}]");
|
log.Information($"Ready to create / update a person? [{ticks}]");
|
||||||
for (int y = 0; y < int.MaxValue; y++)
|
for (int y = 0; y < int.MaxValue; y++)
|
||||||
{
|
{
|
||||||
|
personName = null;
|
||||||
log.Information("Press \"Y\" key to continue, \"N\" key exit or close console");
|
log.Information("Press \"Y\" key to continue, \"N\" key exit or close console");
|
||||||
consoleKey = System.Console.ReadKey().Key;
|
consoleKey = System.Console.ReadKey().Key;
|
||||||
log.Information(". . .");
|
log.Information(". . .");
|
||||||
@ -116,11 +116,12 @@ public class Person
|
|||||||
lastName = null;
|
lastName = null;
|
||||||
for (int f = 0; f < 5; f++)
|
for (int f = 0; f < 5; f++)
|
||||||
{
|
{
|
||||||
segments = firstName.Split(' ');
|
personName = IPerson.GetPersonName(firstName);
|
||||||
if (segments.Length > 1)
|
if (!string.IsNullOrEmpty(personName.First.Value) && !string.IsNullOrEmpty(personName.Last.Value))
|
||||||
lastName = segments[^1];
|
lastName = personName.Last.Value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
personName = null;
|
||||||
log.Information("Enter persons last name (minimum length of two characters)");
|
log.Information("Enter persons last name (minimum length of two characters)");
|
||||||
line = System.Console.ReadLine();
|
line = System.Console.ReadLine();
|
||||||
log.Information(". . .");
|
log.Information(". . .");
|
||||||
@ -132,9 +133,8 @@ public class Person
|
|||||||
}
|
}
|
||||||
if (lastName is null)
|
if (lastName is null)
|
||||||
continue;
|
continue;
|
||||||
segments = firstName.Split(' ');
|
if (personName is not null)
|
||||||
if (segments.Length > 2)
|
middleName = personName.Middle.Value;
|
||||||
middleName = segments[1];
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.Information("Enter persons middle name (press enter if they don't have a middle name)");
|
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();
|
line = System.Console.ReadLine();
|
||||||
log.Information(". . .");
|
log.Information(". . .");
|
||||||
alias = string.IsNullOrEmpty(line) ? string.Empty : line;
|
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 });
|
json = JsonSerializer.Serialize(personName, new JsonSerializerOptions { WriteIndented = true });
|
||||||
log.Information("Is the person \"M\" (Male), \"F\" (Female) or \"U\" (Unknown)");
|
log.Information("Is the person \"M\" (Male), \"F\" (Female) or \"U\" (Unknown)");
|
||||||
consoleKey = System.Console.ReadKey().Key;
|
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)
|
if (consoleKey is not ConsoleKey.M and not ConsoleKey.F and not ConsoleKey.U)
|
||||||
continue;
|
continue;
|
||||||
sex = consoleKey.Value;
|
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;
|
consoleKey = System.Console.ReadKey().Key;
|
||||||
log.Information(". . .");
|
log.Information(". . .");
|
||||||
if (consoleKey is not ConsoleKey.Y and not ConsoleKey.N)
|
if (consoleKey is not ConsoleKey.Y and not ConsoleKey.N)
|
||||||
continue;
|
continue;
|
||||||
deceased = consoleKey == ConsoleKey.Y;
|
alive = consoleKey == ConsoleKey.Y;
|
||||||
dateTime = null;
|
dateTime = null;
|
||||||
approximateYears = null;
|
approximateYears = null;
|
||||||
for (int f = 0; f < 5; f++)
|
for (int f = 0; f < 5; f++)
|
||||||
@ -259,12 +259,9 @@ public class Person
|
|||||||
personKeyFormatted = "2";
|
personKeyFormatted = "2";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
personKey = dateTime.Value.Ticks;
|
hours = IPersonBirthday.GetHour(alive, sex);
|
||||||
if (deceased)
|
personKey = dateTime.Value.AddHours(hours).Ticks;
|
||||||
code = sex is ConsoleKey.M ? "05" : sex is ConsoleKey.F ? "04" : sex is ConsoleKey.U ? "02" : throw new NotImplementedException();
|
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey);
|
||||||
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}";
|
|
||||||
}
|
}
|
||||||
checkDirectory = Path.Combine(personDisplayDirectory, personKeyFormatted);
|
checkDirectory = Path.Combine(personDisplayDirectory, personKeyFormatted);
|
||||||
log.Information($"Working directory <{checkDirectory}>");
|
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) =>
|
bool TestStatic_IsDefaultName(string mappingDefaultName, string value) =>
|
||||||
IsDefaultName(mappingDefaultName, value);
|
IsDefaultName(mappingDefaultName, value);
|
||||||
static bool IsDefaultName(string mappingDefaultName, string value) =>
|
static bool IsDefaultName(string mappingDefaultName, string value) =>
|
||||||
|
@ -23,6 +23,16 @@ public interface IPersonBirthday
|
|||||||
static double? GetAge(Models.PersonBirthday birthday) =>
|
static double? GetAge(Models.PersonBirthday birthday) =>
|
||||||
PersonBirthday.GetAge(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) =>
|
Models.PersonBirthday TestStatic_GetPersonBirthday(long ticks) =>
|
||||||
new(new(ticks));
|
new(new(ticks));
|
||||||
static Models.PersonBirthday GetPersonBirthday(long ticks) =>
|
static Models.PersonBirthday GetPersonBirthday(long ticks) =>
|
||||||
|
@ -166,11 +166,8 @@ internal abstract class Person
|
|||||||
sexLine = "1 SEX U";
|
sexLine = "1 SEX U";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string code;
|
int hours = IPersonBirthday.GetHour(deathLine is null or not "1 DEAT Y", sexLine[6]);
|
||||||
if (deathLine is null or not "1 DEAT Y")
|
string code = hours.ToString("00");
|
||||||
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();
|
|
||||||
if (directory.EndsWith("00"))
|
if (directory.EndsWith("00"))
|
||||||
directory = string.Concat(directory[..^2], code);
|
directory = string.Concat(directory[..^2], code);
|
||||||
else if (directory.EndsWith("01"))
|
else if (directory.EndsWith("01"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user