Component.cs 438 B

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