muffin v7.38
This commit is contained in:
parent
411c0bbe76
commit
e5b98b3d57
35 changed files with 10700 additions and 7610 deletions
37
Questionable/Questionable.Model.Changelog/ChangelogEntry.cs
Normal file
37
Questionable/Questionable.Model.Changelog/ChangelogEntry.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Questionable.Model.Changelog;
|
||||
|
||||
internal sealed record ChangelogEntry(string Version, DateOnly ReleaseDate, List<ChangeEntry> Changes)
|
||||
{
|
||||
public bool IsNewVersion(string? lastViewedVersion)
|
||||
{
|
||||
if (string.IsNullOrEmpty(lastViewedVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CompareVersions(Version, lastViewedVersion) > 0;
|
||||
}
|
||||
|
||||
private static int CompareVersions(string version1, string version2)
|
||||
{
|
||||
int result;
|
||||
int[] array = (from p in version1.Split('.')
|
||||
select int.TryParse(p, out result) ? result : 0).ToArray();
|
||||
int[] array2 = (from p in version2.Split('.')
|
||||
select int.TryParse(p, out result) ? result : 0).ToArray();
|
||||
int num = Math.Max(array.Length, array2.Length);
|
||||
for (int num2 = 0; num2 < num; num2++)
|
||||
{
|
||||
int num3 = ((num2 < array.Length) ? array[num2] : 0);
|
||||
int num4 = ((num2 < array2.Length) ? array2[num2] : 0);
|
||||
if (num3 != num4)
|
||||
{
|
||||
return num3.CompareTo(num4);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue