summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/XSingleton.cs
blob: df9e221d4bcf31902de26fede966873f276bb819 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;

namespace XUtliPoolLib
{
	public abstract class XSingleton<T> : XBaseSingleton where T : new()
	{
		public static T singleton
		{
			get
			{
				return XSingleton<T>._instance;
			}
		}

		private static readonly T _instance = Activator.CreateInstance<T>();

		protected XSingleton()
		{
			bool flag = XSingleton<T>._instance != null;
			if (flag)
			{
				T instance = XSingleton<T>._instance;
				throw new XDoubleNewException(instance.ToString() + " can not be created again.");
			}
		}

		public override bool Init()
		{
			return true;
		}

		public override void Uninit()
		{
		}
	}
}