using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TwitchDesktopNotifications.Core { public interface Singleton { } public class SingletonFactory where T : Singleton, new() { public static Dictionary store = new Dictionary(); public static T GetInstance(){ string name = typeof(T).FullName; if (!store.ContainsKey(name)) { store.Add(name, new T()); } return (T)store[name]; } } }