Cleanup ApiContainer
This commit is contained in:
parent
911cb096de
commit
2b50f4f112
|
@ -1,11 +1,13 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public sealed class ApiContainer : IApiContainer
|
||||
public sealed class ApiContainer
|
||||
{
|
||||
public Dictionary<Type, IExternalApi> Libraries { get; set; }
|
||||
public readonly IReadOnlyDictionary<Type, IExternalApi> Libraries;
|
||||
|
||||
public ICommApi Comm => (ICommApi) Libraries[typeof(ICommApi)];
|
||||
public IEmuClientApi EmuClient => (IEmuClientApi) Libraries[typeof(IEmuClientApi)];
|
||||
|
@ -23,6 +25,6 @@ namespace BizHawk.Client.Common
|
|||
public IUserDataApi UserData => (IUserDataApi) Libraries[typeof(IUserDataApi)];
|
||||
public IToolApi Tool => (IToolApi) Libraries[typeof(IToolApi)];
|
||||
|
||||
public ApiContainer(Dictionary<Type, IExternalApi> libs) => Libraries = libs;
|
||||
public ApiContainer(IReadOnlyDictionary<Type, IExternalApi> libs) => Libraries = libs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public IReadOnlyCollection<Type> AvailableApis => _libs.Keys.ToList();
|
||||
|
||||
public BasicApiProvider(IApiContainer apiContainer) => _libs = apiContainer.Libraries;
|
||||
public BasicApiProvider(ApiContainer apiContainer) => _libs = apiContainer.Libraries;
|
||||
|
||||
public object? GetApi(Type t) => _libs.TryGetValue(t, out var api) ? api : null;
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public interface IApiContainer
|
||||
{
|
||||
Dictionary<Type, IExternalApi> Libraries { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue