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;
///
/// 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();
///
/// 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;
}
///
/// Resets all services to their default implementations (useful for testing)
///
public static void Reset()
{
_bridgeService = null;
_clientService = null;
_pathService = null;
}
}
}