App
This commit is contained in:
24
src/Alma.App/Services/OsInformation.cs
Normal file
24
src/Alma.App/Services/OsInformation.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user