Component.cs 606 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using MongoDB.Bson.Serialization.Attributes;
  2. namespace ETModel
  3. {
  4. [BsonIgnoreExtraElements]
  5. public abstract partial class Component: Disposer
  6. {
  7. [BsonIgnoreIfDefault]
  8. [BsonDefaultValue(0L)]
  9. [BsonElement]
  10. [BsonId]
  11. public long Id { get; set; }
  12. [BsonIgnore]
  13. public Component Parent { get; set; }
  14. public T GetParent<T>() where T : Component
  15. {
  16. return this.Parent as T;
  17. }
  18. [BsonIgnore]
  19. public Entity Entity
  20. {
  21. get
  22. {
  23. return this.Parent as Entity;
  24. }
  25. }
  26. public override void Dispose()
  27. {
  28. if (this.IsDisposed)
  29. {
  30. return;
  31. }
  32. base.Dispose();
  33. }
  34. }
  35. }