mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-22 20:42:24 +00:00
33 lines
769 B
C#
33 lines
769 B
C#
namespace Lantean.QBTMud.Helpers
|
|
{
|
|
internal static class VersionHelper
|
|
{
|
|
private static int? _version;
|
|
|
|
private const int _defaultVersion = 5;
|
|
|
|
public static int DefaultVersion => _defaultVersion;
|
|
|
|
public static int GetMajorVersion(string? version)
|
|
{
|
|
if (_version is not null)
|
|
{
|
|
return _version.Value;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(version))
|
|
{
|
|
return _defaultVersion;
|
|
}
|
|
|
|
if (!Version.TryParse(version?.Replace("v", ""), out var theVersion))
|
|
{
|
|
return _defaultVersion;
|
|
}
|
|
|
|
_version = theVersion.Major;
|
|
|
|
return _version.Value;
|
|
}
|
|
}
|
|
} |