2
0

WindowsApp.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using MediaBrowser.Common.Net;
  2. using MediaBrowser.IsoMounter;
  3. using MediaBrowser.Model.Logging;
  4. using MediaBrowser.Server.Startup.Common;
  5. using MediaBrowser.ServerApplication.Networking;
  6. using System.Collections.Generic;
  7. using System.Reflection;
  8. using CommonIO;
  9. using MediaBrowser.Controller.Power;
  10. namespace MediaBrowser.ServerApplication.Native
  11. {
  12. public class WindowsApp : INativeApp
  13. {
  14. private readonly IFileSystem _fileSystem;
  15. private readonly ILogger _logger;
  16. public WindowsApp(IFileSystem fileSystem, ILogger logger)
  17. {
  18. _fileSystem = fileSystem;
  19. _logger = logger;
  20. }
  21. public List<Assembly> GetAssembliesWithParts()
  22. {
  23. var list = new List<Assembly>();
  24. if (!System.Environment.Is64BitProcess)
  25. {
  26. //list.Add(typeof(PismoIsoManager).Assembly);
  27. }
  28. list.Add(GetType().Assembly);
  29. return list;
  30. }
  31. public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string tempDirectory)
  32. {
  33. ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, tempDirectory);
  34. }
  35. public NativeEnvironment Environment
  36. {
  37. get
  38. {
  39. return new NativeEnvironment
  40. {
  41. OperatingSystem = OperatingSystem.Windows,
  42. SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
  43. OperatingSystemVersionString = System.Environment.OSVersion.VersionString
  44. };
  45. }
  46. }
  47. public bool SupportsLibraryMonitor
  48. {
  49. get { return true; }
  50. }
  51. public bool SupportsRunningAsService
  52. {
  53. get
  54. {
  55. return true;
  56. }
  57. }
  58. public bool IsRunningAsService
  59. {
  60. get;
  61. set;
  62. }
  63. public bool CanSelfRestart
  64. {
  65. get
  66. {
  67. return MainStartup.CanSelfRestart;
  68. }
  69. }
  70. public bool SupportsAutoRunAtStartup
  71. {
  72. get
  73. {
  74. return true;
  75. }
  76. }
  77. public bool CanSelfUpdate
  78. {
  79. get
  80. {
  81. return MainStartup.CanSelfUpdate;
  82. }
  83. }
  84. public void Shutdown()
  85. {
  86. MainStartup.Shutdown();
  87. }
  88. public void Restart(StartupOptions startupOptions)
  89. {
  90. MainStartup.Restart();
  91. }
  92. public void ConfigureAutoRun(bool autorun)
  93. {
  94. Autorun.Configure(autorun, _fileSystem);
  95. }
  96. public INetworkManager CreateNetworkManager(ILogger logger)
  97. {
  98. return new NetworkManager(logger);
  99. }
  100. public void PreventSystemStandby()
  101. {
  102. Standby.PreventSystemStandby();
  103. }
  104. public IPowerManagement GetPowerManagement()
  105. {
  106. return new WindowsPowerManagement(_logger);
  107. }
  108. }
  109. }