Add ApiContainer prop to IExternalApiProvider
This commit is contained in:
parent
29bceb272f
commit
608d7dcff8
|
@ -8,14 +8,14 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class BasicApiProvider : IExternalApiProvider
|
||||
{
|
||||
private readonly IReadOnlyDictionary<Type, IExternalApi> _libs;
|
||||
public IReadOnlyCollection<Type> AvailableApis => Container.Libraries.Keys.ToList();
|
||||
|
||||
public IReadOnlyCollection<Type> AvailableApis => _libs.Keys.ToList();
|
||||
public ApiContainer Container { get; }
|
||||
|
||||
public BasicApiProvider(ApiContainer apiContainer) => _libs = apiContainer.Libraries;
|
||||
public BasicApiProvider(ApiContainer apiContainer) => Container = apiContainer;
|
||||
|
||||
public object? GetApi(Type t) => _libs.TryGetValue(t, out var api) ? api : null;
|
||||
public object? GetApi(Type t) => Container.Libraries.TryGetValue(t, out var api) ? api : null;
|
||||
|
||||
public bool HasApi(Type t) => _libs.ContainsKey(t);
|
||||
public bool HasApi(Type t) => Container.Libraries.ContainsKey(t);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace BizHawk.Client.Common
|
|||
/// <returns>a list of all currently registered <see cref="IExternalApi">APIs</see> that are available</returns>
|
||||
IReadOnlyCollection<Type> AvailableApis { get; }
|
||||
|
||||
ApiContainer Container { get; }
|
||||
|
||||
/// <returns>an instance of the <see cref="IExternalApi"/> <paramref name="t"/> iff available else <see langword="null"/></returns>
|
||||
object? GetApi(Type t);
|
||||
|
||||
|
|
Loading…
Reference in New Issue