using System; using System.Collections.Generic; using Microsoft.Extensions.Configuration; using NLog; namespace ChaosBot { public static class Dependency { private static Dictionary InstanceList; public static void Initialize(IConfiguration appSettingsHandler) { InstanceList = new Dictionary { {typeof(ILogger), Logging.GenLog(appSettingsHandler)} }; } public static T GetInstance() { if (InstanceList.TryGetValue(typeof(T), out object obj)) { return (T) obj; } throw new KeyNotFoundException($"Could not find dependency of type {typeof(T)}"); } } }