add 1.6 support and restore 1.5 compatibility

This commit is contained in:
localavaster
2026-04-07 03:34:45 -06:00
parent 418aad61f2
commit 5a3f6c1cc8
15 changed files with 197 additions and 57 deletions
+8 -2
View File
@@ -49,7 +49,13 @@ public abstract class SingletonFactory<T_base> where T_base : notnull
}
private static T_base GetInternal(Type type)
=> _instances.GetOrAdd(type, static type => (T_base)Activator.CreateInstance(type, true));
{
if (_instances.TryGetValue(type, out var existing))
return existing;
var instance = _instances.GetOrAdd(type, static type => (T_base)Activator.CreateInstance(type, true));
return instance;
}
private static readonly ConcurrentDictionary<Type, T_base> _instances = new();
}
}