Cleanup ApiContainer

This commit is contained in:
YoshiRulz 2020-07-26 05:32:31 +10:00
parent 911cb096de
commit 2b50f4f112
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 6 additions and 14 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
namespace BizHawk.Client.Common
{
public interface IApiContainer
{
Dictionary<Type, IExternalApi> Libraries { get; set; }
}
}