SingletonBaseET.cs 670 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. namespace ET
  3. {
  4. public class SingletonBaseET<T> where T: class,new()
  5. {
  6. private static T _instance;
  7. private static readonly object _lock = new object();
  8. public static T Instance
  9. {
  10. get
  11. {
  12. if (_instance == null)
  13. {
  14. lock (_lock)
  15. {
  16. if (_instance == null)
  17. {
  18. _instance = (T)Activator.CreateInstance(typeof(T), true);
  19. }
  20. }
  21. }
  22. return _instance;
  23. }
  24. }
  25. }
  26. }