WindowsApp.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. public WindowsApp(IFileSystem fileSystem)
  16. {
  17. _fileSystem = fileSystem;
  18. }
  19. public List<Assembly> GetAssembliesWithParts()
  20. {
  21. var list = new List<Assembly>();
  22. if (!System.Environment.Is64BitProcess)
  23. {
  24. //list.Add(typeof(PismoIsoManager).Assembly);
  25. }
  26. list.Add(GetType().Assembly);
  27. return list;
  28. }
  29. public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string tempDirectory)
  30. {
  31. ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, tempDirectory);
  32. }
  33. public NativeEnvironment Environment
  34. {
  35. get
  36. {
  37. return new NativeEnvironment
  38. {
  39. OperatingSystem = OperatingSystem.Windows,
  40. SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
  41. OperatingSystemVersionString = System.Environment.OSVersion.VersionString
  42. };
  43. }
  44. }
  45. public bool SupportsLibraryMonitor
  46. {
  47. get { return true; }
  48. }
  49. public bool SupportsRunningAsService
  50. {
  51. get
  52. {
  53. return true;
  54. }
  55. }
  56. public bool IsRunningAsService
  57. {
  58. get;
  59. set;
  60. }
  61. public bool CanSelfRestart
  62. {
  63. get
  64. {
  65. return MainStartup.CanSelfRestart;
  66. }
  67. }
  68. public bool SupportsAutoRunAtStartup
  69. {
  70. get
  71. {
  72. return true;
  73. }
  74. }
  75. public bool CanSelfUpdate
  76. {
  77. get
  78. {
  79. return MainStartup.CanSelfUpdate;
  80. }
  81. }
  82. public void Shutdown()
  83. {
  84. MainStartup.Shutdown();
  85. }
  86. public void Restart(StartupOptions startupOptions)
  87. {
  88. MainStartup.Restart();
  89. }
  90. public void ConfigureAutoRun(bool autorun)
  91. {
  92. Autorun.Configure(autorun, _fileSystem);
  93. }
  94. public INetworkManager CreateNetworkManager(ILogger logger)
  95. {
  96. return new NetworkManager(logger);
  97. }
  98. public void PreventSystemStandby()
  99. {
  100. Standby.PreventSystemStandby();
  101. }
  102. public IPowerManagement GetPowerManagement()
  103. {
  104. return new WindowsPowerManagement();
  105. }
  106. }
  107. }