public static T Get <T>() { lock (_instances) { if (!_instances.TryGetValue(typeof(T), out var obj)) { SingletonException.Throw <T>($"No instances of singleton {typeof(T)}"); } return((T)obj); } }
public static void Init <T>(this IAutoSingleton <T> singleton) { lock (_instances) { if (_instances.ContainsKey(typeof(T))) { SingletonException.Throw <T>(); } else { _instances[typeof(T)] = singleton; } } }