PlatformHelper.cs 889 Bytes
Newer Older
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
1 2 3 4 5
using System;
using System.Runtime.InteropServices;

namespace LibVLCSharp.Shared
{
Martin Finkel's avatar
Martin Finkel committed
6
    internal class PlatformHelper
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
7
    {
Martin Finkel's avatar
Martin Finkel committed
8
        internal static bool IsWindows
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
9 10 11 12 13 14 15 16
        {
#if NET40
            get => Environment.OSVersion.Platform == PlatformID.Win32NT;
#else
            get => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#endif
        }

Martin Finkel's avatar
Martin Finkel committed
17
        internal static bool IsLinux
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
18 19 20 21 22 23 24 25
        {
#if NET40
            get => Environment.OSVersion.Platform == PlatformID.Unix;
#else
            get => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
#endif
        }

Martin Finkel's avatar
Martin Finkel committed
26
        internal static bool IsMac
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
27 28 29 30 31 32 33 34
        {
#if NET40
            get => false; // no easy way to detect Mac platform host at runtime under net471
#else
            get => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
#endif
        }

Martin Finkel's avatar
Martin Finkel committed
35
        internal static bool IsX64BitProcess => IntPtr.Size == 8;
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
36 37
    }
}