2
0

WindowsApp.cs 2.8 KB

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