Files
Alma/src/Alma.App/Services/OsInformation.cs
2022-11-01 15:01:20 +01:00

24 lines
695 B
C#

using System.Runtime.InteropServices;
namespace Alma.Services;
public class OsInformation : IOsInformation
{
private const string OsIdentifierDefault = "default";
private const string OsIdentifierWin = "windows";
private const string OsIdentifierLinux = "linux";
public string GetOsIdentifier()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return OsIdentifierWin;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return OsIdentifierLinux;
return "unknown";
}
public bool IsOnPlatform(string platform)
{
if (platform == OsIdentifierDefault) return true;
return platform == GetOsIdentifier();
}
}