From 2b50f4f112b2347a6ee0428f38318d272f443ffa Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 26 Jul 2020 05:32:31 +1000 Subject: [PATCH] Cleanup ApiContainer --- src/BizHawk.Client.Common/Api/ApiContainer.cs | 8 +++++--- src/BizHawk.Client.Common/Api/BasicApiProvider.cs | 2 +- .../Api/Interfaces/IApiContainer.cs | 10 ---------- 3 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 src/BizHawk.Client.Common/Api/Interfaces/IApiContainer.cs diff --git a/src/BizHawk.Client.Common/Api/ApiContainer.cs b/src/BizHawk.Client.Common/Api/ApiContainer.cs index 24e1c3e9a8..281e639071 100644 --- a/src/BizHawk.Client.Common/Api/ApiContainer.cs +++ b/src/BizHawk.Client.Common/Api/ApiContainer.cs @@ -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 Libraries { get; set; } + public readonly IReadOnlyDictionary 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 libs) => Libraries = libs; + public ApiContainer(IReadOnlyDictionary libs) => Libraries = libs; } } diff --git a/src/BizHawk.Client.Common/Api/BasicApiProvider.cs b/src/BizHawk.Client.Common/Api/BasicApiProvider.cs index 033a007315..a2d9114f7a 100644 --- a/src/BizHawk.Client.Common/Api/BasicApiProvider.cs +++ b/src/BizHawk.Client.Common/Api/BasicApiProvider.cs @@ -12,7 +12,7 @@ namespace BizHawk.Client.Common public IReadOnlyCollection 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; diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IApiContainer.cs b/src/BizHawk.Client.Common/Api/Interfaces/IApiContainer.cs deleted file mode 100644 index 112dabf79f..0000000000 --- a/src/BizHawk.Client.Common/Api/Interfaces/IApiContainer.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace BizHawk.Client.Common -{ - public interface IApiContainer - { - Dictionary Libraries { get; set; } - } -}