DataSingleton.cs 444 B

123456789101112131415
  1. namespace XGame.Framework.Data
  2. {
  3. /// <summary>
  4. /// IData 的单例基类
  5. /// </summary>
  6. /// <typeparam name="TType"></typeparam>
  7. public abstract class DataSingleton<TType> : IData where TType : DataSingleton<TType>, new()
  8. {
  9. public static TType Instance => DataModule.Instance.GetOrAdd<TType>();
  10. public static void Dispose()
  11. {
  12. DataModule.Instance.Remove<TType>();
  13. }
  14. }
  15. }