only use WMI on Windows
This commit is contained in:
parent
1485d98b24
commit
6f07801b04
|
@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Management;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#if SMAPI_FOR_WINDOWS
|
#if SMAPI_FOR_WINDOWS
|
||||||
|
using System.Management;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
#endif
|
#endif
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
@ -586,19 +586,21 @@ namespace StardewModdingAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get a human-readable name for the current platform.</summary>
|
/// <summary>Get a human-readable name for the current platform.</summary>
|
||||||
|
[SuppressMessage("ReSharper", "EmptyGeneralCatchClause", Justification = "Error suppressed deliberately to fallback to default behaviour.")]
|
||||||
private string GetFriendlyPlatformName()
|
private string GetFriendlyPlatformName()
|
||||||
{
|
{
|
||||||
|
#if SMAPI_FOR_WINDOWS
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (
|
return new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem")
|
||||||
from entry in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
|
.Get()
|
||||||
select entry.GetPropertyValue("Caption").ToString()
|
.Cast<ManagementObject>()
|
||||||
).FirstOrDefault();
|
.Select(entry => entry.GetPropertyValue("Caption").ToString())
|
||||||
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
catch
|
catch { }
|
||||||
{
|
#endif
|
||||||
return Environment.OSVersion.ToString();
|
return Environment.OSVersion.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" Condition="$(OS) == 'Windows_NT'" />
|
||||||
<Reference Include="System.Numerics">
|
<Reference Include="System.Numerics">
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
Loading…
Reference in New Issue