Move const usage out of Shared

This commit is contained in:
2022-09-14 22:32:37 -07:00
parent ad28ab2d38
commit 409c020426
28 changed files with 190 additions and 160 deletions

View File

@ -5,15 +5,15 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class Mapping
{
internal static double GetDeterministicHashCodeKey(Models.Item item, Models.Face face)
internal static double GetDeterministicHashCodeKey(int locationDigits, Models.Item item, Models.Face face)
{
if (item.Property?.Id is null || item.ImageFileHolder is null || face.Location?.NormalizedPixelPercentage is null)
throw new NullReferenceException();
double result = IMapping.GetDeterministicHashCodeKeyValue(item.Property.Id.Value, face.Location.NormalizedPixelPercentage.Value);
double result = IMapping.GetDeterministicHashCodeKeyValue(locationDigits, item.Property.Id.Value, face.Location.NormalizedPixelPercentage.Value);
return result;
}
private static void UseKeyValuePairsSaveFaceEncoding(Dictionary<int, List<Models.Face>> keyValuePairs, string file, int id, int normalizedPixelPercentageValue, double deterministicHashCodeKey, string extensionLowered)
private static void UseKeyValuePairsSaveFaceEncoding(int locationDigits, Dictionary<int, List<Models.Face>> keyValuePairs, string file, int id, int normalizedPixelPercentageValue, double deterministicHashCodeKey, string extensionLowered)
{
string json;
string checkFile;
@ -24,7 +24,7 @@ internal abstract class Mapping
{
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
continue;
if (normalizedPixelPercentageValue != face.Location.NormalizedPixelPercentage.Value && deterministicHashCodeKey != IMapping.GetDeterministicHashCodeKeyValue(id, face.Location.NormalizedPixelPercentage.Value))
if (normalizedPixelPercentageValue != face.Location.NormalizedPixelPercentage.Value && deterministicHashCodeKey != IMapping.GetDeterministicHashCodeKeyValue(locationDigits, id, face.Location.NormalizedPixelPercentage.Value))
continue;
collection.Add(face);
}
@ -43,7 +43,7 @@ internal abstract class Mapping
}
}
private static (int?, int?, double?) GetReversedDeterministicHashCodeKeysFromSegments(bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file, string[] segments)
private static (int?, int?, double?) GetReversedDeterministicHashCodeKeysFromSegments(int locationDigits, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file, string[] segments)
{
double? result;
if (segments.Length != 3)
@ -55,14 +55,14 @@ internal abstract class Mapping
result = null;
else
{
result = IMapping.GetDeterministicHashCodeKeyValue(idValue, normalizedPixelPercentageValue);
result = IMapping.GetDeterministicHashCodeKeyValue(locationDigits, idValue, normalizedPixelPercentageValue);
if (keyValuePairsAny && keyValuePairs.ContainsKey(idValue))
UseKeyValuePairsSaveFaceEncoding(keyValuePairs, file, idValue, normalizedPixelPercentageValue, result.Value, $".{segments[2]}");
UseKeyValuePairsSaveFaceEncoding(locationDigits, keyValuePairs, file, idValue, normalizedPixelPercentageValue, result.Value, $".{segments[2]}");
}
return new(idValue, normalizedPixelPercentageValue, result);
}
internal static (int?, int?) GetReversedDeterministicHashCodeKey(bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file)
internal static (int?, int?) GetReversedDeterministicHashCodeKey(int locationDigits, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file)
{
int? id;
int? normalizedPixelPercentage;
@ -75,7 +75,7 @@ internal abstract class Mapping
else
{
string[] segments = fileName.Split('.');
(id, normalizedPixelPercentage, double? result) = GetReversedDeterministicHashCodeKeysFromSegments(keyValuePairsAny, keyValuePairs, file, segments);
(id, normalizedPixelPercentage, double? result) = GetReversedDeterministicHashCodeKeysFromSegments(locationDigits, keyValuePairsAny, keyValuePairs, file, segments);
if (result is null)
{
id = null;