diff --git a/Libraries/SPTarkov.DI/DependencyInjectionRegistrator.cs b/Libraries/SPTarkov.DI/DependencyInjectionRegistrator.cs index 229ac99e..8d5c772d 100644 --- a/Libraries/SPTarkov.DI/DependencyInjectionRegistrator.cs +++ b/Libraries/SPTarkov.DI/DependencyInjectionRegistrator.cs @@ -98,20 +98,19 @@ public static class DependencyInjectionRegistrator } foreach (var matchedConstructor in constructorInfos) - foreach (var parameterInfo in matchedConstructor.GetParameters() - .Where( - p => p.ParameterType.IsGenericType && - p.ParameterType.GetGenericTypeDefinition().FullName == typeName - )) { - var parameters = parameterInfo.ParameterType.GetGenericArguments(); - var typedGeneric = valueTuple.TypeToRegister.MakeGenericType(parameters); - RegisterComponent( - builderServices, - valueTuple.InjectableAttribute.InjectionType, - parameterInfo.ParameterType, - typedGeneric - ); + var constructorParams = matchedConstructor.GetParameters(); + foreach (var parameterInfo in constructorParams.Where(x => IsMatchingGenericType(x,typeName))) + { + var parameters = parameterInfo.ParameterType.GetGenericArguments(); + var typedGeneric = valueTuple.TypeToRegister.MakeGenericType(parameters); + RegisterComponent( + builderServices, + valueTuple.InjectableAttribute.InjectionType, + parameterInfo.ParameterType, + typedGeneric + ); + } } } catch (Exception e) @@ -121,6 +120,12 @@ public static class DependencyInjectionRegistrator } } + private static bool IsMatchingGenericType(ParameterInfo paramInfo, string typeName) + { + return paramInfo.ParameterType.IsGenericType && + paramInfo.ParameterType.GetGenericTypeDefinition().FullName == typeName; + } + private static void RegisterComponent( IServiceCollection builderServices, InjectionType injectionType,