aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/EnvironmentInfo
diff options
context:
space:
mode:
authorLogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>2019-01-05 16:22:18 -0800
committerGitHub <noreply@github.com>2019-01-05 16:22:18 -0800
commit8ff89fdc0c30f595a171ffc550f907ef22b6212a (patch)
tree6bae45c12ea8530e5af2ceaceaa50e715ea7087c /Emby.Server.Implementations/EnvironmentInfo
parent4eaeee7be24a35e697731da1403c12df8f4f753a (diff)
parentb39585cbf6ccc519161e8f6420daaa046a26bf32 (diff)
Merge pull request #5 from jellyfin/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/EnvironmentInfo')
-rw-r--r--Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs60
1 files changed, 16 insertions, 44 deletions
diff --git a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs
index 7655051095..03e10e7ea3 100644
--- a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs
+++ b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs
@@ -1,46 +1,33 @@
using System;
using System.IO;
using MediaBrowser.Model.System;
+using System.Runtime.InteropServices;
namespace Emby.Server.Implementations.EnvironmentInfo
{
+ // TODO: Rework @bond
public class EnvironmentInfo : IEnvironmentInfo
{
- private Architecture? _customArchitecture;
- private MediaBrowser.Model.System.OperatingSystem? _customOperatingSystem;
-
- public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
+ public EnvironmentInfo(MediaBrowser.Model.System.OperatingSystem operatingSystem)
{
- get
- {
- if (_customOperatingSystem.HasValue)
- {
- return _customOperatingSystem.Value;
- }
-
- switch (Environment.OSVersion.Platform)
- {
- case PlatformID.MacOSX:
- return MediaBrowser.Model.System.OperatingSystem.OSX;
- case PlatformID.Win32NT:
- return MediaBrowser.Model.System.OperatingSystem.Windows;
- case PlatformID.Unix:
- return MediaBrowser.Model.System.OperatingSystem.Linux;
- }
-
- return MediaBrowser.Model.System.OperatingSystem.Windows;
- }
- set
- {
- _customOperatingSystem = value;
- }
+ OperatingSystem = operatingSystem;
}
+ public MediaBrowser.Model.System.OperatingSystem OperatingSystem { get; private set; }
+
public string OperatingSystemName
{
get
{
- return Environment.OSVersion.Platform.ToString();
+ switch (OperatingSystem)
+ {
+ case MediaBrowser.Model.System.OperatingSystem.Android: return "Android";
+ case MediaBrowser.Model.System.OperatingSystem.BSD: return "BSD";
+ case MediaBrowser.Model.System.OperatingSystem.Linux: return "Linux";
+ case MediaBrowser.Model.System.OperatingSystem.OSX: return "macOS";
+ case MediaBrowser.Model.System.OperatingSystem.Windows: return "Windows";
+ default: throw new Exception($"Unknown OS {OperatingSystem}");
+ }
}
}
@@ -60,22 +47,7 @@ namespace Emby.Server.Implementations.EnvironmentInfo
}
}
- public Architecture SystemArchitecture
- {
- get
- {
- if (_customArchitecture.HasValue)
- {
- return _customArchitecture.Value;
- }
-
- return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
- }
- set
- {
- _customArchitecture = value;
- }
- }
+ public Architecture SystemArchitecture { get { return RuntimeInformation.OSArchitecture; } }
public string GetEnvironmentVariable(string name)
{