Using PersonContainer for PersonDisplayDirectoryName
This commit is contained in:
parent
1f8c4569ee
commit
17532d2698
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -5,7 +5,7 @@
|
|||||||
"name": "Rename",
|
"name": "Rename",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build-Rename",
|
"preLaunchTask": "Build-Rename",
|
||||||
"program": "${workspaceFolder}/Rename/bin/Debug/net9.0/win-x64/AA.Rename.dll",
|
"program": "${workspaceFolder}/Rename/bin/Debug/net9.0/win-x64/AA.Rename.dll",
|
||||||
"args": [
|
"args": [
|
||||||
"s"
|
"s"
|
||||||
@ -22,7 +22,7 @@
|
|||||||
"name": "Compare",
|
"name": "Compare",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build-Compare",
|
"preLaunchTask": "Build-Compare",
|
||||||
"program": "${workspaceFolder}/Compare/bin/Debug/net9.0/win-x64/AA.Compare.dll",
|
"program": "${workspaceFolder}/Compare/bin/Debug/net9.0/win-x64/AA.Compare.dll",
|
||||||
"args": [
|
"args": [
|
||||||
"s"
|
"s"
|
||||||
|
@ -17,6 +17,7 @@ internal static class MappedLogicA
|
|||||||
private static List<MappedFile> GetDisplayDirectoryAllFiles(PeopleSettings peopleSettings, ICompareSettings compareSettings, ReadOnlyCollections readOnlyCollections)
|
private static List<MappedFile> GetDisplayDirectoryAllFiles(PeopleSettings peopleSettings, ICompareSettings compareSettings, ReadOnlyCollections readOnlyCollections)
|
||||||
{
|
{
|
||||||
List<MappedFile> results = [];
|
List<MappedFile> results = [];
|
||||||
|
FilePath filePath;
|
||||||
MappedFile mappedFile;
|
MappedFile mappedFile;
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
List<string> distinct = [];
|
List<string> distinct = [];
|
||||||
@ -27,14 +28,15 @@ internal static class MappedLogicA
|
|||||||
continue;
|
continue;
|
||||||
for (int i = personContainer.DisplayDirectoryAllFilePaths.Count - 1; i > -1; i--)
|
for (int i = personContainer.DisplayDirectoryAllFilePaths.Count - 1; i > -1; i--)
|
||||||
{
|
{
|
||||||
if (personContainer.DisplayDirectoryAllFilePaths[i].ExtensionLowered != compareSettings.FacesFileNameExtension)
|
filePath = personContainer.DisplayDirectoryAllFilePaths[i];
|
||||||
|
if (filePath.ExtensionLowered != compareSettings.FacesFileNameExtension)
|
||||||
continue;
|
continue;
|
||||||
if (distinct.Contains(personContainer.DisplayDirectoryAllFilePaths[i].Name))
|
if (distinct.Contains(filePath.Name))
|
||||||
continue;
|
continue;
|
||||||
distinct.Add(personContainer.DisplayDirectoryAllFilePaths[i].Name);
|
distinct.Add(filePath.Name);
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(peopleSettings.PersonBirthdayFormat, personContainer.Key.Value);
|
personKeyFormatted = IPersonBirthday.GetFormatted(peopleSettings.PersonBirthdayFormat, personContainer.Key.Value);
|
||||||
personKeyFormattedAndKeyTicksAndDisplayDirectoryName = new(personKeyFormatted, personContainer.Key.Value, personContainer.DisplayDirectoryAllFilePaths[i].Name);
|
personKeyFormattedAndKeyTicksAndDisplayDirectoryName = new(personKeyFormatted, personContainer.Key.Value, filePath.Name);
|
||||||
mappedFile = new(personKeyFormattedAndKeyTicksAndDisplayDirectoryName, personContainer.DisplayDirectoryName, personContainer.DisplayDirectoryAllFilePaths[i]);
|
mappedFile = new(personKeyFormattedAndKeyTicksAndDisplayDirectoryName, personContainer.DisplayDirectoryName, filePath);
|
||||||
results.Add(mappedFile);
|
results.Add(mappedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,8 +53,11 @@ internal static class MappedLogicA
|
|||||||
MappedFile mappedFile;
|
MappedFile mappedFile;
|
||||||
List<string> distinct = [];
|
List<string> distinct = [];
|
||||||
PersonBirthday? personBirthday;
|
PersonBirthday? personBirthday;
|
||||||
PersonKeyFormattedAndKeyTicksAndDisplayDirectoryName personKeyFormattedAndKeyTicksAndDisplayDirectoryName;
|
PersonContainer? personContainer;
|
||||||
|
string? personDisplayDirectoryName;
|
||||||
results.AddRange(GetDisplayDirectoryAllFiles(peopleSettings, compareSettings, readOnlyCollections));
|
results.AddRange(GetDisplayDirectoryAllFiles(peopleSettings, compareSettings, readOnlyCollections));
|
||||||
|
ReadOnlyDictionary<long, PersonContainer> keyValuePairs = PersonContainer.Extract(readOnlyCollections.PersonContainers);
|
||||||
|
PersonKeyFormattedAndKeyTicksAndDisplayDirectoryName personKeyFormattedAndKeyTicksAndDisplayDirectoryName;
|
||||||
foreach (MappedLogicB.Record record in records)
|
foreach (MappedLogicB.Record record in records)
|
||||||
{
|
{
|
||||||
personBirthday = IPersonBirthday.GetPersonBirthday(peopleSettings.PersonBirthdayFormat, record.PersonKeyFormatted);
|
personBirthday = IPersonBirthday.GetPersonBirthday(peopleSettings.PersonBirthdayFormat, record.PersonKeyFormatted);
|
||||||
@ -62,8 +67,12 @@ internal static class MappedLogicA
|
|||||||
continue;
|
continue;
|
||||||
distinct.Add(record.MappedFaceFilePath.Name);
|
distinct.Add(record.MappedFaceFilePath.Name);
|
||||||
personKey = personBirthday.Value.Ticks;
|
personKey = personBirthday.Value.Ticks;
|
||||||
personKeyFormattedAndKeyTicksAndDisplayDirectoryName = new(record.PersonKeyFormatted, personKey, record.PersonDisplayDirectoryName);
|
if (!keyValuePairs.TryGetValue(personKey, out personContainer))
|
||||||
mappedFile = new(personKeyFormattedAndKeyTicksAndDisplayDirectoryName, record.PersonDisplayDirectoryName, record.MappedFaceFilePath);
|
personDisplayDirectoryName = record.PersonDisplayDirectoryName;
|
||||||
|
else
|
||||||
|
personDisplayDirectoryName = personContainer.DisplayDirectoryName;
|
||||||
|
personKeyFormattedAndKeyTicksAndDisplayDirectoryName = new(record.PersonKeyFormatted, personKey, personDisplayDirectoryName);
|
||||||
|
mappedFile = new(personKeyFormattedAndKeyTicksAndDisplayDirectoryName, personDisplayDirectoryName, record.MappedFaceFilePath);
|
||||||
results.Add(mappedFile);
|
results.Add(mappedFile);
|
||||||
}
|
}
|
||||||
for (int i = results.Count - 1; i > -1; i--)
|
for (int i = results.Count - 1; i > -1; i--)
|
||||||
|
@ -40,6 +40,18 @@ public record PersonContainer(int? ApproximateYears,
|
|||||||
public static bool? IsKeyIsMaxBirthday(PersonContainer personContainer) =>
|
public static bool? IsKeyIsMaxBirthday(PersonContainer personContainer) =>
|
||||||
personContainer.Birthdays is null || personContainer.Key is null ? null : personContainer.Key.Value == personContainer.Birthdays.First().Value.Ticks;
|
personContainer.Birthdays is null || personContainer.Key is null ? null : personContainer.Key.Value == personContainer.Birthdays.First().Value.Ticks;
|
||||||
|
|
||||||
|
public static ReadOnlyDictionary<long, PersonContainer> Extract(ReadOnlyCollection<PersonContainer> personContainers)
|
||||||
|
{
|
||||||
|
Dictionary<long, PersonContainer> results = [];
|
||||||
|
foreach (PersonContainer personContainer in personContainers)
|
||||||
|
{
|
||||||
|
if (personContainer.Key is null || results.ContainsKey(personContainer.Key.Value))
|
||||||
|
continue;
|
||||||
|
results.Add(personContainer.Key.Value, personContainer);
|
||||||
|
}
|
||||||
|
return results.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
@ -3,7 +3,9 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Shared.Models;
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
public record PersonKeyFormattedAndKeyTicksAndDisplayDirectoryName(string KeyFormatted, long KeyTicks, string? DisplayDirectoryName)
|
public record PersonKeyFormattedAndKeyTicksAndDisplayDirectoryName(string KeyFormatted,
|
||||||
|
long KeyTicks,
|
||||||
|
string? DisplayDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user