using System; using System.Collections.Generic; using System.Text; namespace Barotrauma.MoreLevelContent.Shared.Utils { public abstract class Singleton where T : class { /// /// Static instance. Needs to use lambda expression /// to construct an instance (since constructor is private). /// private static readonly Lazy sInstance = new Lazy(() => CreateInstanceOfT()); /// /// Gets the instance of this singleton. /// public static T Instance => sInstance.Value; /// /// Creates an instance of T via reflection since T's constructor is expected to be private. /// /// private static T CreateInstanceOfT() => Activator.CreateInstance(typeof(T), true) as T; public abstract void Setup(); } }