2016-11-04 19:51:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-04-08 18:31:18 +00:00
|
|
|
|
using System.IO;
|
2016-11-04 19:51:59 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediaBrowser.Model.System;
|
|
|
|
|
|
|
|
|
|
namespace Emby.Common.Implementations.EnvironmentInfo
|
|
|
|
|
{
|
|
|
|
|
public class EnvironmentInfo : IEnvironmentInfo
|
|
|
|
|
{
|
2016-11-11 08:13:11 +00:00
|
|
|
|
public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; }
|
2016-12-22 04:47:59 +00:00
|
|
|
|
public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; }
|
2016-11-11 08:13:11 +00:00
|
|
|
|
|
2017-02-07 08:23:45 +00:00
|
|
|
|
public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
|
2016-11-04 19:51:59 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-22 04:47:59 +00:00
|
|
|
|
if (CustomOperatingSystem.HasValue)
|
|
|
|
|
{
|
|
|
|
|
return CustomOperatingSystem.Value;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-29 17:30:28 +00:00
|
|
|
|
#if NET46
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
#elif NETSTANDARD1_6
|
2016-11-04 19:51:59 +00:00
|
|
|
|
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
|
|
{
|
2017-04-29 17:30:28 +00:00
|
|
|
|
return OperatingSystem.OSX;
|
2016-11-04 19:51:59 +00:00
|
|
|
|
}
|
|
|
|
|
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
|
{
|
2017-04-29 17:30:28 +00:00
|
|
|
|
return OperatingSystem.Windows;
|
2016-11-04 19:51:59 +00:00
|
|
|
|
}
|
|
|
|
|
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
{
|
2017-04-29 17:30:28 +00:00
|
|
|
|
return OperatingSystem.Linux;
|
2016-11-04 19:51:59 +00:00
|
|
|
|
}
|
2017-04-29 17:30:28 +00:00
|
|
|
|
#endif
|
2016-11-04 19:51:59 +00:00
|
|
|
|
return MediaBrowser.Model.System.OperatingSystem.Windows;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string OperatingSystemName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-04-29 17:30:28 +00:00
|
|
|
|
#if NET46
|
|
|
|
|
return Environment.OSVersion.Platform.ToString();
|
|
|
|
|
#elif NETSTANDARD1_6
|
|
|
|
|
return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
|
|
|
|
|
#endif
|
|
|
|
|
return "Operating System";
|
2016-11-04 19:51:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string OperatingSystemVersion
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-04-29 17:30:28 +00:00
|
|
|
|
#if NET46
|
|
|
|
|
return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
|
|
|
|
|
#elif NETSTANDARD1_6
|
|
|
|
|
return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
|
|
|
|
|
#endif
|
|
|
|
|
return "1.0";
|
2016-11-04 19:51:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-11 08:13:11 +00:00
|
|
|
|
|
2017-04-08 18:31:18 +00:00
|
|
|
|
public char PathSeparator
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Path.PathSeparator;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-11 08:13:11 +00:00
|
|
|
|
public MediaBrowser.Model.System.Architecture SystemArchitecture
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (CustomArchitecture.HasValue)
|
|
|
|
|
{
|
|
|
|
|
return CustomArchitecture.Value;
|
|
|
|
|
}
|
2017-04-29 17:30:28 +00:00
|
|
|
|
#if NET46
|
|
|
|
|
return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
|
|
|
|
|
#elif NETSTANDARD1_6
|
|
|
|
|
switch(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture)
|
2016-11-11 08:13:11 +00:00
|
|
|
|
{
|
|
|
|
|
case System.Runtime.InteropServices.Architecture.Arm:
|
|
|
|
|
return MediaBrowser.Model.System.Architecture.Arm;
|
|
|
|
|
case System.Runtime.InteropServices.Architecture.Arm64:
|
|
|
|
|
return MediaBrowser.Model.System.Architecture.Arm64;
|
|
|
|
|
case System.Runtime.InteropServices.Architecture.X64:
|
|
|
|
|
return MediaBrowser.Model.System.Architecture.X64;
|
|
|
|
|
case System.Runtime.InteropServices.Architecture.X86:
|
|
|
|
|
return MediaBrowser.Model.System.Architecture.X86;
|
|
|
|
|
}
|
2017-04-29 17:30:28 +00:00
|
|
|
|
#endif
|
2016-11-11 08:13:11 +00:00
|
|
|
|
return MediaBrowser.Model.System.Architecture.X64;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-13 21:04:21 +00:00
|
|
|
|
|
|
|
|
|
public string GetEnvironmentVariable(string name)
|
|
|
|
|
{
|
|
|
|
|
return Environment.GetEnvironmentVariable(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual string GetUserId()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-11-21 08:54:53 +00:00
|
|
|
|
|
|
|
|
|
public string StackTrace
|
|
|
|
|
{
|
|
|
|
|
get { return Environment.StackTrace; }
|
|
|
|
|
}
|
2016-11-29 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
public void SetProcessEnvironmentVariable(string name, string value)
|
|
|
|
|
{
|
|
|
|
|
Environment.SetEnvironmentVariable(name, value);
|
|
|
|
|
}
|
2016-11-04 19:51:59 +00:00
|
|
|
|
}
|
2017-04-29 17:30:28 +00:00
|
|
|
|
}
|