Unit.cs 625 B

1234567891011121314151617181920212223242526272829
  1. namespace IFramework
  2. {
  3. /// <summary>
  4. /// 基类
  5. /// </summary>
  6. public abstract class Unit : IUnit
  7. {
  8. private bool _disposed;
  9. /// <summary>
  10. /// 是否已经释放
  11. /// </summary>
  12. public bool disposed { get { return _disposed; } }
  13. /// <summary>
  14. /// 释放时
  15. /// </summary>
  16. protected abstract void OnDispose();
  17. /// <summary>
  18. /// 释放
  19. /// </summary>
  20. public virtual void Dispose()
  21. {
  22. if (_disposed) return;
  23. OnDispose();
  24. _disposed = true;
  25. }
  26. }
  27. }