From 5752a4a36c671d3e96dd6e389a21bddfa199adbe Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Tue, 22 Oct 2019 18:14:54 -0500 Subject: [PATCH] Minor code quality changes in PluginInitInjector --- IPA.Loader/Loader/PluginInitInjector.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IPA.Loader/Loader/PluginInitInjector.cs b/IPA.Loader/Loader/PluginInitInjector.cs index 7dc2679c..552f815b 100644 --- a/IPA.Loader/Loader/PluginInitInjector.cs +++ b/IPA.Loader/Loader/PluginInitInjector.cs @@ -33,7 +33,7 @@ namespace IPA.Loader /// the function to call for injection. public static void AddInjector(Type type, InjectParameter injector) { - injectors.Add(new Tuple(type, injector)); + injectors.Add(Tuple.Create(type, injector)); } private static readonly List> injectors = new List> @@ -60,14 +60,14 @@ namespace IPA.Loader var initArgs = new List(); var initParams = init.GetParameters(); - Dictionary, object> previousValues = - new Dictionary, object>(injectors.Count); + var previousValues = new Dictionary, object>(injectors.Count); foreach (var param in initParams) { var paramType = param.ParameterType; var value = paramType.GetDefault(); + // TODO: make this work on closest match foreach (var pair in injectors.Where(t => paramType.IsAssignableFrom(t.Item1))) { object prev = null; @@ -75,7 +75,7 @@ namespace IPA.Loader prev = previousValues[pair]; var val = pair.Item2?.Invoke(prev, param, meta); - + if (previousValues.ContainsKey(pair)) previousValues[pair] = val; else