Settings for the server are now combined with the settings from the SDK. This introduces a large breaking change and a migration should be created. This refactor utilizes .NET Configuration and the Options pattern. This will allow for the overriding of any setting using envionment variables. It also means that Settings.yml can be used to override any .NET configuration. A SettingsProvider implementation was created, and any updating of settings was changed from SettingsService.SaveSettings() to SettingsProvider.Update(s => { ... })
33 lines
No EOL
1 KiB
C#
33 lines
No EOL
1 KiB
C#
using System.Diagnostics;
|
|
using System.Reflection;
|
|
using LANCommander.Server.Services;
|
|
using LANCommander.Server.Services.Abstractions;
|
|
using LANCommander.Server.Services.Models;
|
|
using LANCommander.Server.Settings.Enums;
|
|
using Semver;
|
|
|
|
namespace LANCommander.Server.Providers;
|
|
|
|
public class VersionProvider : IVersionProvider
|
|
{
|
|
public SemVersion GetCurrentVersion()
|
|
{
|
|
var version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
|
|
|
|
return SemVersion.Parse(version);
|
|
}
|
|
|
|
public ReleaseChannel GetReleaseChannel(SemVersion version)
|
|
{
|
|
if (version.IsRelease)
|
|
return ReleaseChannel.Stable;
|
|
|
|
if (version.IsPrerelease && version.PrereleaseIdentifiers.Any(pi => pi.Value == "nightly"))
|
|
return ReleaseChannel.Nightly;
|
|
|
|
if (version.IsPrerelease)
|
|
return ReleaseChannel.Prerelease;
|
|
|
|
throw new ArgumentException("Could not parse version number", nameof(version));
|
|
}
|
|
} |