mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
35 lines
771 B
C#
35 lines
771 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;
|
|
}
|
|
}
|
|
}
|