1234567891011121314151617181920 |
- using System;
- public class Singleton<T>
- {
- protected static readonly T ms_instance = Activator.CreateInstance<T>();
- public static T Instance
- {
- get
- {
- return Singleton<T>.ms_instance;
- }
- }
- protected Singleton()
- {
- this.OnInstanceCreate();
- }
- protected virtual void OnInstanceCreate()
- {
- }
- }
|