add 1.6 support and restore 1.5 compatibility
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user