ListComponent.cs 890 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * 封装List,用于重用
  3. */
  4. using System.Collections.Generic;
  5. namespace ETModel
  6. {
  7. public class ListComponent <T> : Entity
  8. {
  9. public List<T> List = new List<T>();
  10. public override void Dispose()
  11. {
  12. if (this.IsDisposed)
  13. {
  14. return;
  15. }
  16. base.Dispose();
  17. this.List.Clear();
  18. }
  19. }
  20. public class ListComponentDisposeChildren <T> : Entity where T : Entity
  21. {
  22. public List<T> List = new List<T>();
  23. public override void Dispose()
  24. {
  25. if (this.IsDisposed)
  26. {
  27. return;
  28. }
  29. base.Dispose();
  30. foreach (T entity in this.List)
  31. {
  32. entity.Dispose();
  33. }
  34. this.List.Clear();
  35. }
  36. }
  37. }