using System; namespace MCPForUnity.Editor.Services { /// /// Service locator for accessing MCP services without dependency injection /// public static class MCPServiceLocator { private static IBridgeControlService _bridgeService; private static IClientConfigurationService _clientService; private static IPathResolverService _pathService; private static ITestRunnerService _testRunnerService; /// /// Gets the bridge control service /// public static IBridgeControlService Bridge => _bridgeService ??= new BridgeControlService(); /// /// Gets the client configuration service /// public static IClientConfigurationService Client => _clientService ??= new ClientConfigurationService(); /// /// Gets the path resolver service /// public static IPathResolverService Paths => _pathService ??= new PathResolverService(); /// /// Gets the Unity test runner service /// public static ITestRunnerService Tests => _testRunnerService ??= new TestRunnerService(); /// /// Registers a custom implementation for a service (useful for testing) /// /// The service interface type /// The implementation to register public static void Register(T implementation) where T : class { if (implementation is IBridgeControlService b) _bridgeService = b; else if (implementation is IClientConfigurationService c) _clientService = c; else if (implementation is IPathResolverService p) _pathService = p; else if (implementation is ITestRunnerService t) _testRunnerService = t; } /// /// Resets all services to their default implementations (useful for testing) /// public static void Reset() { (_bridgeService as IDisposable)?.Dispose(); (_clientService as IDisposable)?.Dispose(); (_pathService as IDisposable)?.Dispose(); (_testRunnerService as IDisposable)?.Dispose(); _bridgeService = null; _clientService = null; _pathService = null; _testRunnerService = null; } } }