WindowsApp.cs 3.1 KB

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