implement CompareTo
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Pilz.Updating;
|
||||
|
||||
public class AppVersion(Version version, int build, Channels channel)
|
||||
public class AppVersion(Version version, int build, Channels channel) : IComparable, IComparable<AppVersion>
|
||||
{
|
||||
// P r o p e r t i e s
|
||||
|
||||
@@ -81,6 +81,42 @@ public class AppVersion(Version version, int build, Channels channel)
|
||||
return new AppVersion(version, build, channel);
|
||||
}
|
||||
|
||||
// C o m p a r e
|
||||
|
||||
public int CompareTo(object appVersion)
|
||||
{
|
||||
return CompareTo(appVersion as AppVersion);
|
||||
}
|
||||
|
||||
public int CompareTo(AppVersion appVersion)
|
||||
{
|
||||
if (appVersion is null)
|
||||
return 1;
|
||||
|
||||
if (Version != appVersion.Version)
|
||||
{
|
||||
if (Version > appVersion.Version)
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Channel != appVersion.Channel)
|
||||
{
|
||||
if (Channel < appVersion.Channel)
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Build != appVersion.Build)
|
||||
{
|
||||
if (Build > appVersion.Build)
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// O p e r a t o r s
|
||||
|
||||
public static bool operator >(AppVersion a, AppVersion b)
|
||||
|
||||
Reference in New Issue
Block a user