diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 3f1ad98745..edd74c8b74 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -48,7 +48,17 @@ namespace BizHawk.Client.EmuHawk public Type[] GetDependencies() where T : IToolForm { - var attribute = (RequiredServices)typeof(T) + return GetDependencies(typeof(T)); + } + + /// + /// Gets all the IEmulatorServices the tool needs, as defined in its + /// RequiredServices attribute. If no attribute is defined, returns an + /// empty array. + /// + public Type[] GetDependencies(Type toolType) + { + var attribute = (RequiredServices)toolType .GetCustomAttributes(typeof(RequiredServices), false) .FirstOrDefault(); @@ -65,8 +75,17 @@ namespace BizHawk.Client.EmuHawk public bool IsAvailable() where T : IToolForm { - return GetDependencies() - .All(t => Global.Emulator.ServiceProvider.HasService(typeof(T))); + return IsAvailable(typeof(T)); + } + + /// + /// Determines whether a tool is available, considering its dependencies + /// and the services provided by the emulator core. + /// + public bool IsAvailable(Type toolType) + { + return GetDependencies(toolType) + .All(t => Global.Emulator.ServiceProvider.HasService(toolType)); } ///