Sorting without ... improvements

This commit is contained in:
2022-12-21 22:54:50 -07:00
parent 44d8eaf5fb
commit 2da3db7aa5
25 changed files with 353 additions and 358 deletions

View File

@ -27,51 +27,42 @@ internal abstract class Mapping
return new(id, normalizedRectangle, extensionLowered, needsFacesFileNameExtension);
}
private static (int?, int?, List<Models.Mapping>?) GetConvertedsFromSegments(string facesFileNameExtension, bool idToMappingCollectionAny, Dictionary<int, List<Models.Mapping>> idToMappingCollection, string fileName)
private static (int?, int?) GetConvertedFromSegments(string facesFileNameExtension, string fileName)
{
int? id;
int? normalizedRectangle;
List<Models.Mapping>? mappingCollection;
(string? Id, string? NormalizedRectangle, string? ExtensionLowered, bool? Check) segments = GetSegments(facesFileNameExtension, fileName);
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedRectangle) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
{
id = null;
mappingCollection = null;
normalizedRectangle = null;
}
else if (!int.TryParse(segments.Id, out int idValue) || !int.TryParse(segments.NormalizedRectangle, out int normalizedRectangleValue))
{
id = null;
mappingCollection = null;
normalizedRectangle = null;
}
else
{
id = idValue;
normalizedRectangle = normalizedRectangleValue;
if (!idToMappingCollectionAny || !idToMappingCollection.ContainsKey(idValue))
mappingCollection = null;
else
mappingCollection = idToMappingCollection[idValue];
}
return new(id, normalizedRectangle, mappingCollection);
return new(id, normalizedRectangle);
}
internal static (int?, int?, List<Models.Mapping>?) GetConverted(string facesFileNameExtension, bool idToMappingCollectionAny, Dictionary<int, List<Models.Mapping>> idToMappingCollection, string file)
internal static (int?, int?) GetConverted(string facesFileNameExtension, string file)
{
int? id;
int? normalizedRectangle;
List<Models.Mapping>? mappingCollection;
string fileName = Path.GetFileName(file);
if (fileName.Length >= 2 && !fileName[1..].Contains('-'))
(id, normalizedRectangle, mappingCollection) = GetConvertedsFromSegments(facesFileNameExtension, idToMappingCollectionAny, idToMappingCollection, fileName);
(id, normalizedRectangle) = GetConvertedFromSegments(facesFileNameExtension, fileName);
else
{
id = null;
mappingCollection = null;
normalizedRectangle = null;
}
return new(id, normalizedRectangle, mappingCollection);
return new(id, normalizedRectangle);
}
internal static int GetAreaPermille(int faceAreaPermille, int bottom, int height, int left, int right, int top, int width)