using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BrewMonster { public abstract class Singleton where T : class, new() { private static readonly Lazy _instance = new Lazy(() => new T()); public static T Instance => _instance.Value; // Protected constructor prevents external instantiation protected Singleton() { if (_instance.IsValueCreated) throw new InvalidOperationException($"Singleton<{typeof(T).Name}> already created!"); } } }