From e31da370527c37aee50c99f97db0fd9d780986e8 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Thu, 2 Feb 2023 20:32:00 +0100 Subject: [PATCH] fix(core): do not try to create stateful instance in case the entity is already present --- Core/NosSmooth.Core/NosSmooth.Core.csproj | 2 +- Core/NosSmooth.Core/Stateful/StatefulRepository.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Core/NosSmooth.Core/NosSmooth.Core.csproj b/Core/NosSmooth.Core/NosSmooth.Core.csproj index b7b3633..b0846bd 100644 --- a/Core/NosSmooth.Core/NosSmooth.Core.csproj +++ b/Core/NosSmooth.Core/NosSmooth.Core.csproj @@ -6,7 +6,7 @@ net7.0;netstandard2.1 Rutherther NosSmooth Core library allowing implementing nostale client, handling packets and commands. - 3.4.1 + 3.4.2 Fix StatefulInjector returning Func instead of the object. diff --git a/Core/NosSmooth.Core/Stateful/StatefulRepository.cs b/Core/NosSmooth.Core/Stateful/StatefulRepository.cs index d9bd32d..997aadc 100644 --- a/Core/NosSmooth.Core/Stateful/StatefulRepository.cs +++ b/Core/NosSmooth.Core/Stateful/StatefulRepository.cs @@ -76,7 +76,12 @@ public class StatefulRepository }, (_, objectDictionary) => { - objectDictionary.TryAdd(statefulEntityType, ActivatorUtilities.CreateInstance(services, statefulEntityType)); + if (!objectDictionary.ContainsKey(statefulEntityType)) + { + objectDictionary.TryAdd + (statefulEntityType, ActivatorUtilities.CreateInstance(services, statefulEntityType)); + } + return objectDictionary; } ); -- 2.49.0