WindowsApp.cs 2.4 KB

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