add Pilz.Runtime.RuntimeInformationsEx & Pilz.OSType

This commit is contained in:
schedpas
2020-09-15 14:39:30 +02:00
parent b6d2572737
commit ff059104c6
3 changed files with 39 additions and 0 deletions

View File

@@ -83,6 +83,8 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="Runtime\OSType.vb" />
<Compile Include="Runtime\RuntimeInformationsEx.vb" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx"> <EmbeddedResource Include="My Project\Resources.resx">

9
Pilz/Runtime/OSType.vb Normal file
View File

@@ -0,0 +1,9 @@
Namespace Runtime
Public Enum OSType
Windows
Linux
OSX
End Enum
End Namespace

View File

@@ -0,0 +1,28 @@
Imports System.Runtime.InteropServices
Namespace Runtime
Public Module RuntimeInformationsEx
Public ReadOnly Property OSPlattform
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