Beispiel #1
0
 public virtual void Dispose()
 {
     if (this == Instance)
     {
         SingletonDock.Unregister <T>();
     }
 }
Beispiel #2
0
        protected Singleton()
        {
            var instance = Instance;

            if (instance != null && instance != this)
            {
                throw new Exception(string.Format("Singleton instance {0} already exists.", typeof(T)));
            }
            SingletonDock.Register <T>(this as T, true);
        }
Beispiel #3
0
        protected bool UnregisterInstance()
        {
            if (SingletonDock <T> .Instance == this)
            {
                SingletonDock <T> .Unregister();
            }

            if (instance != this)
            {
                return(false);
            }
            instance = null;
            return(true);
        }