WindowsApp.cs 2.9 KB

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