You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Reflection;
- using SUISS.Core.Utilities;
-
- namespace SUISSEngine
- {
- public abstract class Singleton<T> where T : Singleton<T>, new()
- {
- public Singleton()
- {
- }
-
- public static T Instance
- {
- get
- {
- if (Singleton<T>._instance == null)
- {
- try
- {
- Singleton<T>._instance = Activator.CreateInstance<T>();
- }
- catch (TargetInvocationException ex)
- {
- throw new Exception("Exception in initializer: " + typeof(T).GetCompatibleTypeInfo().FullName + "\n" + ex.InnerException.ToString());
- }
- }
- return Singleton<T>._instance;
- }
- }
-
- public static bool IsAvailable
- {
- get
- {
- return Singleton<T>._instance != null;
- }
- }
-
- private static T _instance;
- }
- }
|