From 926a69a06a302775591107142f3b1a6cff7fe4b5 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 17 Jan 2023 21:45:06 +0100 Subject: [PATCH] fix(game): do not add game responder multiple times --- .../NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs b/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs index a78b3c0..a742d58 100644 --- a/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs +++ b/Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs @@ -148,6 +148,11 @@ public static class ServiceCollectionExtensions /// The collection. public static IServiceCollection AddGameResponder(this IServiceCollection serviceCollection, Type gameResponder) { + if (serviceCollection.Any(x => x.ImplementationType == gameResponder)) + { // already added... assuming every packet responder was added even though that may not be the case. + return serviceCollection; + } + if (!gameResponder.GetInterfaces().Any ( i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IGameResponder<>) -- 2.48.1