PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/util/Services.cs

#
C# | 147 lines | 108 code | 20 blank | 19 comment | 18 complexity | f7758d0bcac27b1ee5617f008dac813a MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2007, Charlie Poole
  3. // This is free software licensed under the NUnit license. You may
  4. // obtain a copy of the license at http://nunit.org
  5. // ****************************************************************
  6. using System;
  7. using NUnit.Core;
  8. using NUnit.Core.Extensibility;
  9. namespace NUnit.Util
  10. {
  11. /// <summary>
  12. /// Services is a utility class, which is used to provide access
  13. /// to services in a more simple way than is supported by te
  14. /// ServiceManager class itself.
  15. /// </summary>
  16. public class Services
  17. {
  18. #region AddinManager
  19. private static AddinManager addinManager;
  20. public static AddinManager AddinManager
  21. {
  22. get
  23. {
  24. if (addinManager == null )
  25. addinManager = (AddinManager)ServiceManager.Services.GetService( typeof( AddinManager ) );
  26. return addinManager;
  27. }
  28. }
  29. #endregion
  30. #region AddinRegistry
  31. private static IAddinRegistry addinRegistry;
  32. public static IAddinRegistry AddinRegistry
  33. {
  34. get
  35. {
  36. if (addinRegistry == null)
  37. addinRegistry = (IAddinRegistry)ServiceManager.Services.GetService( typeof( IAddinRegistry ) );
  38. return addinRegistry;
  39. }
  40. }
  41. #endregion
  42. #region DomainManager
  43. private static DomainManager domainManager;
  44. public static DomainManager DomainManager
  45. {
  46. get
  47. {
  48. if ( domainManager == null )
  49. domainManager = (DomainManager)ServiceManager.Services.GetService( typeof( DomainManager ) );
  50. return domainManager;
  51. }
  52. }
  53. #endregion
  54. #region UserSettings
  55. private static ISettings userSettings;
  56. public static ISettings UserSettings
  57. {
  58. get
  59. {
  60. if ( userSettings == null )
  61. userSettings = (ISettings)ServiceManager.Services.GetService( typeof( ISettings ) );
  62. // Temporary fix needed to run TestDomain tests in test AppDomain
  63. // TODO: Figure out how to set up the test domain correctly
  64. if ( userSettings == null )
  65. userSettings = new SettingsService();
  66. return userSettings;
  67. }
  68. }
  69. #endregion
  70. #region RecentFilesService
  71. private static RecentFiles recentFiles;
  72. public static RecentFiles RecentFiles
  73. {
  74. get
  75. {
  76. if ( recentFiles == null )
  77. recentFiles = (RecentFiles)ServiceManager.Services.GetService( typeof( RecentFiles ) );
  78. return recentFiles;
  79. }
  80. }
  81. #endregion
  82. #region TestLoader
  83. private static TestLoader loader;
  84. public static TestLoader TestLoader
  85. {
  86. get
  87. {
  88. if ( loader == null )
  89. loader = (TestLoader)ServiceManager.Services.GetService( typeof( TestLoader ) );
  90. return loader;
  91. }
  92. }
  93. #endregion
  94. #region TestAgency
  95. private static TestAgency agency;
  96. public static TestAgency TestAgency
  97. {
  98. get
  99. {
  100. if ( agency == null )
  101. agency = (TestAgency)ServiceManager.Services.GetService( typeof( TestAgency ) );
  102. // Temporary fix needed to run ProcessRunner tests in test AppDomain
  103. // TODO: Figure out how to set up the test domain correctly
  104. // if ( agency == null )
  105. // {
  106. // agency = new TestAgency();
  107. // agency.Start();
  108. // }
  109. return agency;
  110. }
  111. }
  112. #endregion
  113. #region ProjectLoader
  114. private static ProjectService projectService;
  115. public static ProjectService ProjectService
  116. {
  117. get
  118. {
  119. if ( projectService == null )
  120. projectService = (ProjectService)
  121. ServiceManager.Services.GetService( typeof( ProjectService ) );
  122. return projectService;
  123. }
  124. }
  125. #endregion
  126. }
  127. }