Component.cs 405 B

123456789101112131415161718192021222324252627282930
  1. using MongoDB.Bson.Serialization.Attributes;
  2. namespace Hotfix
  3. {
  4. public abstract class Component : Disposer
  5. {
  6. [BsonIgnore]
  7. public Entity Parent { get; set; }
  8. public T GetParent<T>() where T : Entity
  9. {
  10. return this.Parent as T;
  11. }
  12. protected Component()
  13. {
  14. this.Id = 1;
  15. }
  16. public override void Dispose()
  17. {
  18. if (this.Id == 0)
  19. {
  20. return;
  21. }
  22. base.Dispose();
  23. }
  24. }
  25. }