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.
30 lines
694 B
30 lines
694 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ScadaTool.Helper
|
|
{
|
|
/// <summary>
|
|
/// 单例辅助类
|
|
/// </summary>
|
|
public class SingletonMode<T> where T : class
|
|
{
|
|
public static T _Instance;
|
|
public static T Instance()
|
|
{
|
|
Type type = typeof(T);
|
|
lock (type)
|
|
{
|
|
if (SingletonMode<T>._Instance == null)
|
|
{
|
|
SingletonMode<T>._Instance = (Activator.CreateInstance(typeof(T), true) as T);
|
|
}
|
|
return SingletonMode<T>._Instance;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|