Redesigned the DiscordBotCore by splitting it into multiple projects. Created a WebUI and preparing to remove the DiscordBot application
This commit is contained in:
46
DiscordBotCore.Utilities/OperatingSystem.cs
Normal file
46
DiscordBotCore.Utilities/OperatingSystem.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
namespace DiscordBotCore.Utilities;
|
||||
|
||||
public class OperatingSystem
|
||||
{
|
||||
public enum OperatingSystemEnum : int
|
||||
{
|
||||
Windows = 0,
|
||||
Linux = 1,
|
||||
MacOs = 2
|
||||
}
|
||||
|
||||
public static OperatingSystemEnum GetOperatingSystem()
|
||||
{
|
||||
if(System.OperatingSystem.IsLinux()) return OperatingSystemEnum.Linux;
|
||||
if(System.OperatingSystem.IsWindows()) return OperatingSystemEnum.Windows;
|
||||
if(System.OperatingSystem.IsMacOS()) return OperatingSystemEnum.MacOs;
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public static string GetOperatingSystemString(OperatingSystemEnum os)
|
||||
{
|
||||
return os switch
|
||||
{
|
||||
OperatingSystemEnum.Windows => "Windows",
|
||||
OperatingSystemEnum.Linux => "Linux",
|
||||
OperatingSystemEnum.MacOs => "MacOS",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
public static OperatingSystemEnum GetOperatingSystemFromString(string os)
|
||||
{
|
||||
return os.ToLower() switch
|
||||
{
|
||||
"windows" => OperatingSystemEnum.Windows,
|
||||
"linux" => OperatingSystemEnum.Linux,
|
||||
"macos" => OperatingSystemEnum.MacOs,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
public static int GetOperatingSystemInt()
|
||||
{
|
||||
return (int) GetOperatingSystem();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user