namespace CrazyStudio.Core.Common
{
    public class SingletonProvider<T> where T : new()
    {
        private SingletonProvider() { }
        private static readonly object SyncObject = new();
        private static T? _singleton;

        public static T Instance
        {
            get
            {
                if (null == _singleton)
                {
                    lock (SyncObject)
                    {
                        _singleton = new T();
                    }
                }
                return _singleton;
            }
        }
    }
}
