2
0

WindowsApp.cs 2.7 KB

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