Remove PlatformAbstractions
This commit is contained in:
parent
40f0bb1b45
commit
32cade2542
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace MusicStore
|
||||
{
|
||||
|
|
@ -29,8 +28,7 @@ namespace MusicStore
|
|||
{
|
||||
if (_isWindows == null)
|
||||
{
|
||||
_isWindows = PlatformServices.Default.Runtime.OperatingSystem.Equals(
|
||||
"Windows", StringComparison.OrdinalIgnoreCase);
|
||||
_isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
}
|
||||
|
||||
return _isWindows.Value;
|
||||
|
|
@ -43,10 +41,7 @@ namespace MusicStore
|
|||
{
|
||||
if (_isMono == null)
|
||||
{
|
||||
_isMono = string.Equals(
|
||||
PlatformServices.Default.Runtime.RuntimeType,
|
||||
"Mono",
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
_isMono = Type.GetType("Mono.Runtime") != null;
|
||||
}
|
||||
|
||||
return _isMono.Value;
|
||||
|
|
@ -59,7 +54,7 @@ namespace MusicStore
|
|||
{
|
||||
if (_isNano == null)
|
||||
{
|
||||
var osVersion = new Version(PlatformServices.Default.Runtime.OperatingSystemVersion ?? "");
|
||||
var osVersion = new Version(RtlGetVersion() ?? string.Empty);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -95,5 +90,35 @@ namespace MusicStore
|
|||
return !IsRunningOnWindows || IsRunningOnMono || IsRunningOnNanoServer;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct RTL_OSVERSIONINFOEX
|
||||
{
|
||||
internal uint dwOSVersionInfoSize;
|
||||
internal uint dwMajorVersion;
|
||||
internal uint dwMinorVersion;
|
||||
internal uint dwBuildNumber;
|
||||
internal uint dwPlatformId;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
internal string szCSDVersion;
|
||||
}
|
||||
|
||||
// This call avoids the shimming Windows does to report old versions
|
||||
[DllImport("ntdll")]
|
||||
private static extern int RtlGetVersion(out RTL_OSVERSIONINFOEX lpVersionInformation);
|
||||
|
||||
internal static string RtlGetVersion()
|
||||
{
|
||||
RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();
|
||||
osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
|
||||
if (RtlGetVersion(out osvi) == 0)
|
||||
{
|
||||
return $"{osvi.dwMajorVersion}.{osvi.dwMinorVersion}.{osvi.dwBuildNumber}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using Microsoft.Extensions.Configuration;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using MusicStore.Components;
|
||||
using MusicStore.Models;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue