Save Possibly New Person Containers
This commit is contained in:
@ -4,5 +4,6 @@ public interface IFaceDistance
|
||||
{
|
||||
|
||||
List<Face> GetMatchingFaces(double faceDistanceTolerance, string checkFile, List<Face> faces);
|
||||
void SavePossiblyNewPersonContainers(Properties.IPropertyConfiguration propertyConfiguration, string personBirthdayFormat, string resizeFilenameExtension, Dictionary<long, PersonContainer> personKeyToPersonContainer, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer);
|
||||
|
||||
}
|
@ -32,6 +32,10 @@ public class PersonContainer : Properties.IPersonContainer
|
||||
this(approximateYears, null, new PersonBirthday[] { personBirthday }, Array.Empty<string>(), personDisplayDirectoryName, personKey)
|
||||
{ }
|
||||
|
||||
public PersonContainer(PersonBirthday personBirthday, string personDisplayDirectoryName) :
|
||||
this(Stateless.Methods.IAge.GetApproximateYears(personDisplayDirectoryName), Stateless.Methods.IPerson.GetPerson(personDisplayDirectoryName, personBirthday.Value.Ticks, personBirthday), new PersonBirthday[] { personBirthday }, Array.Empty<string>(), personDisplayDirectoryName, personBirthday.Value.Ticks)
|
||||
{ }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
|
15
Shared/Models/Properties/IPropertyConfiguration.cs
Normal file
15
Shared/Models/Properties/IPropertyConfiguration.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
public interface IPropertyConfiguration
|
||||
{
|
||||
|
||||
public string DateGroup { init; get; }
|
||||
public string[] PropertyContentCollectionFiles { init; get; }
|
||||
public string ResultAllInOne { init; get; }
|
||||
public string ResultCollection { init; get; }
|
||||
public string ResultContent { init; get; }
|
||||
public string ResultSingleton { init; get; }
|
||||
public string RootDirectory { get; }
|
||||
public string[] VerifyToSeason { init; get; }
|
||||
|
||||
}
|
@ -3,13 +3,34 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IAge
|
||||
{ // ...
|
||||
|
||||
(int, TimeSpan) TestStatic_GetAge(long minuendTicks, long subtrahendTicks);
|
||||
static (int, TimeSpan) GetAge(long minuendTicks, long subtrahendTicks) => Age.GetAge(minuendTicks, subtrahendTicks);
|
||||
(int, TimeSpan) TestStatic_GetAge(long minuendTicks, long subtrahendTicks) =>
|
||||
GetAge(minuendTicks, subtrahendTicks);
|
||||
static (int, TimeSpan) GetAge(long minuendTicks, long subtrahendTicks) =>
|
||||
Age.GetAge(minuendTicks, subtrahendTicks);
|
||||
|
||||
(int, TimeSpan) TestStatic_GetAge(long minuendTicks, DateTime subtrahend);
|
||||
static (int, TimeSpan) GetAge(long minuendTicks, DateTime subtrahend) => Age.GetAge(minuendTicks, subtrahend);
|
||||
(int, TimeSpan) TestStatic_GetAge(long minuendTicks, DateTime subtrahend) =>
|
||||
GetAge(minuendTicks, subtrahend);
|
||||
static (int, TimeSpan) GetAge(long minuendTicks, DateTime subtrahend) =>
|
||||
Age.GetAge(minuendTicks, subtrahend);
|
||||
|
||||
(int, TimeSpan) TestStatic_GetAge(DateTime minuend, DateTime subtrahend);
|
||||
static (int, TimeSpan) GetAge(DateTime minuend, DateTime subtrahend) => Age.GetAge(minuend, subtrahend);
|
||||
(int, TimeSpan) TestStatic_GetAge(DateTime minuend, DateTime subtrahend) =>
|
||||
GetAge(minuend, subtrahend);
|
||||
static (int, TimeSpan) GetAge(DateTime minuend, DateTime subtrahend) =>
|
||||
Age.GetAge(minuend, subtrahend);
|
||||
|
||||
char[] TestStatic_GetChars() =>
|
||||
GetChars();
|
||||
static char[] GetChars() =>
|
||||
new char[] { '!', '^', '_', '~' };
|
||||
|
||||
int? TestStatic_GetApproximateYears(string personDisplayDirectoryName, char[] chars) =>
|
||||
GetApproximateYears(personDisplayDirectoryName, chars);
|
||||
static int? GetApproximateYears(string personDisplayDirectoryName, char[] chars) =>
|
||||
Age.GetApproximateYears(personDisplayDirectoryName, chars);
|
||||
|
||||
int? TestStatic_GetApproximateYears(string personDisplayDirectoryName) =>
|
||||
GetApproximateYears(personDisplayDirectoryName);
|
||||
static int? GetApproximateYears(string personDisplayDirectoryName) =>
|
||||
GetApproximateYears(personDisplayDirectoryName, GetChars());
|
||||
|
||||
}
|
@ -3,32 +3,39 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IPath
|
||||
{ // ...
|
||||
|
||||
string TestStatic_GetRelativePath(string path, int length);
|
||||
static string GetRelativePath(string path, int length)
|
||||
=> XPath.GetRelativePath(path, length, forceExtensionToLower: false);
|
||||
string TestStatic_GetRelativePath(string path, int length) =>
|
||||
GetRelativePath(path, length);
|
||||
static string GetRelativePath(string path, int length) =>
|
||||
XPath.GetRelativePath(path, length, forceExtensionToLower: false);
|
||||
|
||||
bool TestStatic_DeleteEmptyDirectories(string rootDirectory);
|
||||
static bool DeleteEmptyDirectories(string rootDirectory)
|
||||
=> XPath.DeleteEmptyDirectories(rootDirectory);
|
||||
bool TestStatic_DeleteEmptyDirectories(string rootDirectory) =>
|
||||
DeleteEmptyDirectories(rootDirectory);
|
||||
static bool DeleteEmptyDirectories(string rootDirectory) =>
|
||||
XPath.DeleteEmptyDirectories(rootDirectory);
|
||||
|
||||
List<string> TestStatic_GetDirectoryNames(string directory);
|
||||
static List<string> GetDirectoryNames(string directory)
|
||||
=> XPath.GetDirectoryNames(directory);
|
||||
string[] TestStatic_GetDirectoryNames(string directory) =>
|
||||
GetDirectoryNames(directory);
|
||||
static string[] GetDirectoryNames(string directory) =>
|
||||
XPath.GetDirectoryNames(directory).ToArray();
|
||||
|
||||
string TestStatic_GetRelativePath(string path, int length, bool forceExtensionToLower);
|
||||
static string GetRelativePath(string path, int length, bool forceExtensionToLower)
|
||||
=> XPath.GetRelativePath(path, length, forceExtensionToLower);
|
||||
string TestStatic_GetRelativePath(string path, int length, bool forceExtensionToLower) =>
|
||||
GetRelativePath(path, length, forceExtensionToLower);
|
||||
static string GetRelativePath(string path, int length, bool forceExtensionToLower) =>
|
||||
XPath.GetRelativePath(path, length, forceExtensionToLower);
|
||||
|
||||
bool TestStatic_WriteAllText(string path, string contents, bool updateDateWhenMatches, bool compareBeforeWrite);
|
||||
static bool WriteAllText(string path, string contents, bool updateDateWhenMatches, bool compareBeforeWrite, DateTime? updateToWhenMatches = null)
|
||||
=> XPath.WriteAllText(path, contents, updateDateWhenMatches, compareBeforeWrite, updateToWhenMatches);
|
||||
bool TestStatic_WriteAllText(string path, string contents, bool updateDateWhenMatches, bool compareBeforeWrite, DateTime? updateToWhenMatches = null) =>
|
||||
WriteAllText(path, contents, updateDateWhenMatches, compareBeforeWrite, updateToWhenMatches);
|
||||
static bool WriteAllText(string path, string contents, bool updateDateWhenMatches, bool compareBeforeWrite, DateTime? updateToWhenMatches = null) =>
|
||||
XPath.WriteAllText(path, contents, updateDateWhenMatches, compareBeforeWrite, updateToWhenMatches);
|
||||
|
||||
(int level, List<string> directories) TestStatic_Get(string rootDirectory, string sourceDirectory);
|
||||
static (int level, List<string> directories) Get(string rootDirectory, string sourceDirectory)
|
||||
=> XPath.Get(rootDirectory, sourceDirectory);
|
||||
(int level, List<string> directories) TestStatic_Get(string rootDirectory, string sourceDirectory) =>
|
||||
Get(rootDirectory, sourceDirectory);
|
||||
static (int level, List<string> directories) Get(string rootDirectory, string sourceDirectory) =>
|
||||
XPath.Get(rootDirectory, sourceDirectory);
|
||||
|
||||
string TestStatic_GetDirectory(string sourceDirectory, int level, string directoryName);
|
||||
static string GetDirectory(string sourceDirectory, int level, string directoryName)
|
||||
=> XPath.GetDirectory(sourceDirectory, level, directoryName);
|
||||
string TestStatic_GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
||||
GetDirectory(sourceDirectory, level, directoryName);
|
||||
static string GetDirectory(string sourceDirectory, int level, string directoryName) =>
|
||||
XPath.GetDirectory(sourceDirectory, level, directoryName);
|
||||
|
||||
}
|
@ -10,10 +10,10 @@ public interface IPerson
|
||||
static string GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
|
||||
PersonBirthday.GetFileFullName(storage, personBirthdayFormat, person.Birthday);
|
||||
|
||||
Models.Person TestStatic_GetPerson(string resultAllInOne, long personKey, Models.PersonBirthday personBirthday) =>
|
||||
GetPerson(resultAllInOne, personKey, personBirthday);
|
||||
static Models.Person GetPerson(string resultAllInOne, long personKey, Models.PersonBirthday personBirthday) =>
|
||||
Person.GetPerson(personKey, personBirthday, new string[] { resultAllInOne });
|
||||
Models.Person TestStatic_GetPerson(string personDisplayDirectoryName, long personKey, Models.PersonBirthday personBirthday) =>
|
||||
GetPerson(personDisplayDirectoryName, personKey, personBirthday);
|
||||
static Models.Person GetPerson(string personDisplayDirectoryName, long personKey, Models.PersonBirthday personBirthday) =>
|
||||
Person.GetPerson(personKey, personBirthday, personDisplayDirectoryName.Split(IAge.GetChars()));
|
||||
|
||||
Models.Person TestStatic_GetPerson(long personKey, string[] segments) =>
|
||||
GetPerson(personKey, segments);
|
||||
|
@ -83,7 +83,7 @@ internal abstract class PersonContainer
|
||||
internal static List<Models.PersonContainer> GetPersonContainers(Properties.IStorage storage, string personBirthdayFormat)
|
||||
{
|
||||
List<Models.PersonContainer> results;
|
||||
char[] chars = new char[] { '!', '^', '_', '~' };
|
||||
char[] chars = IAge.GetChars();
|
||||
string a2PeopleSingletonDirectory = Path.Combine(storage.PeopleRootDirectory, "{}");
|
||||
if (!Directory.Exists(a2PeopleSingletonDirectory))
|
||||
_ = Directory.CreateDirectory(a2PeopleSingletonDirectory);
|
||||
|
@ -104,21 +104,33 @@ internal abstract class XPath
|
||||
internal static List<string> GetDirectoryNames(string directory)
|
||||
{
|
||||
List<string> results = new();
|
||||
string? fileName;
|
||||
string? checkDirectory = directory;
|
||||
string? pathRoot = Path.GetPathRoot(directory);
|
||||
string extension = Path.GetExtension(directory);
|
||||
if (string.IsNullOrEmpty(pathRoot))
|
||||
throw new NullReferenceException(nameof(pathRoot));
|
||||
if (Directory.Exists(directory))
|
||||
results.Add(Path.GetFileName(directory));
|
||||
{
|
||||
fileName = Path.GetFileName(directory);
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
results.Add(fileName);
|
||||
}
|
||||
else if ((string.IsNullOrEmpty(extension) || extension.Length > 3) && !File.Exists(directory))
|
||||
results.Add(Path.GetFileName(directory));
|
||||
{
|
||||
fileName = Path.GetFileName(directory);
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
results.Add(fileName);
|
||||
}
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
||||
if (string.IsNullOrEmpty(checkDirectory) || checkDirectory == pathRoot)
|
||||
break;
|
||||
results.Add(Path.GetFileName(checkDirectory));
|
||||
fileName = Path.GetFileName(checkDirectory);
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
continue;
|
||||
results.Add(fileName);
|
||||
}
|
||||
results.Add(pathRoot);
|
||||
results.Reverse();
|
||||
|
Reference in New Issue
Block a user