convert VB to C#
This commit is contained in:
10
Pilz/Runtime/OSType.cs
Normal file
10
Pilz/Runtime/OSType.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
namespace Pilz.Runtime
|
||||
{
|
||||
public enum OSType
|
||||
{
|
||||
Windows,
|
||||
Linux,
|
||||
OSX
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
Namespace Runtime
|
||||
|
||||
Public Enum OSType
|
||||
Windows
|
||||
Linux
|
||||
OSX
|
||||
End Enum
|
||||
|
||||
End Namespace
|
||||
32
Pilz/Runtime/RuntimeInformationsEx.cs
Normal file
32
Pilz/Runtime/RuntimeInformationsEx.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using global::System.Runtime.InteropServices;
|
||||
|
||||
namespace Pilz.Runtime
|
||||
{
|
||||
public static class RuntimeInformationsEx
|
||||
{
|
||||
private static OSType? oSType = null;
|
||||
public static OSType OSType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (oSType is null)
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
case object _ when RuntimeInformation.IsOSPlatform(OSPlatform.Windows):
|
||||
oSType = OSType.Windows;
|
||||
break;
|
||||
case object _ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux):
|
||||
oSType = OSType.Linux;
|
||||
break;
|
||||
case object _ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX):
|
||||
oSType = OSType.OSX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (OSType)OSType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
Namespace Runtime
|
||||
|
||||
Public Module RuntimeInformationsEx
|
||||
|
||||
Public ReadOnly Property OSType As OSType
|
||||
Get
|
||||
Static t As OSType? = Nothing
|
||||
|
||||
If t Is Nothing Then
|
||||
Select Case True
|
||||
Case RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
t = OSType.Windows
|
||||
Case RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|
||||
t = OSType.Linux
|
||||
Case RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
|
||||
t = OSType.OSX
|
||||
End Select
|
||||
End If
|
||||
|
||||
Return t
|
||||
End Get
|
||||
End Property
|
||||
|
||||
End Module
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user