Disposer.cs 439 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using Model;
  3. namespace Hotfix
  4. {
  5. public abstract class Disposer : Object, IDisposable
  6. {
  7. public long Id { get; set; }
  8. public bool IsFromPool { get; set; }
  9. protected Disposer()
  10. {
  11. this.Id = IdGenerater.GenerateId();
  12. }
  13. protected Disposer(long id)
  14. {
  15. this.Id = id;
  16. }
  17. public virtual void Dispose()
  18. {
  19. this.Id = 0;
  20. if (this.IsFromPool)
  21. {
  22. ObjectPool.Instance.Recycle(this);
  23. }
  24. }
  25. }
  26. }