Merge branch 'refs/heads/cuttingedge-merge-ServerV2' into cuttingedge

This commit is contained in:
Glax 2024-09-11 14:41:35 +02:00
commit a94186455b

View File

@ -58,8 +58,9 @@ public readonly struct Chapter : IComparable
public int CompareTo(object? obj) public int CompareTo(object? obj)
{ {
if (obj is Chapter otherChapter) if(obj is not Chapter otherChapter)
{ throw new ArgumentException($"{obj} can not be compared to {this}");
if (float.TryParse(volumeNumber, GlobalBase.numberFormatDecimalPoint, out float volumeNumberFloat) && if (float.TryParse(volumeNumber, GlobalBase.numberFormatDecimalPoint, out float volumeNumberFloat) &&
float.TryParse(chapterNumber, GlobalBase.numberFormatDecimalPoint, out float chapterNumberFloat) && float.TryParse(chapterNumber, GlobalBase.numberFormatDecimalPoint, out float chapterNumberFloat) &&
float.TryParse(otherChapter.volumeNumber, GlobalBase.numberFormatDecimalPoint, float.TryParse(otherChapter.volumeNumber, GlobalBase.numberFormatDecimalPoint,
@ -67,21 +68,15 @@ public readonly struct Chapter : IComparable
float.TryParse(otherChapter.chapterNumber, GlobalBase.numberFormatDecimalPoint, float.TryParse(otherChapter.chapterNumber, GlobalBase.numberFormatDecimalPoint,
out float otherChapterNumberFloat)) out float otherChapterNumberFloat))
{ {
return volumeNumberFloat.CompareTo(otherVolumeNumberFloat) switch
switch (volumeNumberFloat.CompareTo(otherVolumeNumberFloat))
{ {
case < 0: <0 => -1,
return -1; >0 => 1,
case > 0: _ => chapterNumberFloat.CompareTo(otherChapterNumberFloat)
return 1; };
default:
return chapterNumberFloat.CompareTo(otherChapterNumberFloat);
}
} }
else throw new FormatException($"Value could not be parsed"); else throw new FormatException($"Value could not be parsed");
} }
throw new ArgumentException($"{obj} can not be compared to {this}");
}
/// <summary> /// <summary>
/// Checks if a chapter-archive is already present /// Checks if a chapter-archive is already present