WindowsApp.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using MediaBrowser.Common.IO;
  2. using MediaBrowser.Common.Net;
  3. using MediaBrowser.IsoMounter;
  4. using MediaBrowser.Model.Logging;
  5. using MediaBrowser.Server.Startup.Common;
  6. using MediaBrowser.ServerApplication.Networking;
  7. using System.Collections.Generic;
  8. using System.Reflection;
  9. using CommonIO;
  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. list.Add(typeof(PismoIsoManager).Assembly);
  23. list.Add(GetType().Assembly);
  24. return list;
  25. }
  26. public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string tempDirectory)
  27. {
  28. ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, tempDirectory);
  29. }
  30. public NativeEnvironment Environment
  31. {
  32. get
  33. {
  34. return new NativeEnvironment
  35. {
  36. OperatingSystem = OperatingSystem.Windows,
  37. SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
  38. OperatingSystemVersionString = System.Environment.OSVersion.VersionString
  39. };
  40. }
  41. }
  42. public bool SupportsLibraryMonitor
  43. {
  44. get { return true; }
  45. }
  46. public bool SupportsRunningAsService
  47. {
  48. get
  49. {
  50. return true;
  51. }
  52. }
  53. public bool IsRunningAsService
  54. {
  55. get;
  56. set;
  57. }
  58. public bool CanSelfRestart
  59. {
  60. get
  61. {
  62. return MainStartup.CanSelfRestart;
  63. }
  64. }
  65. public bool SupportsAutoRunAtStartup
  66. {
  67. get
  68. {
  69. return true;
  70. }
  71. }
  72. public bool CanSelfUpdate
  73. {
  74. get
  75. {
  76. return MainStartup.CanSelfUpdate;
  77. }
  78. }
  79. public void Shutdown()
  80. {
  81. MainStartup.Shutdown();
  82. }
  83. public void Restart(StartupOptions startupOptions)
  84. {
  85. MainStartup.Restart();
  86. }
  87. public void ConfigureAutoRun(bool autorun)
  88. {
  89. Autorun.Configure(autorun, _fileSystem);
  90. }
  91. public INetworkManager CreateNetworkManager(ILogger logger)
  92. {
  93. return new NetworkManager(logger);
  94. }
  95. public void PreventSystemStandby()
  96. {
  97. Standby.PreventSystemStandby();
  98. }
  99. }
  100. }