Component.cs 587 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using MongoDB.Bson.Serialization.Attributes;
  2. namespace Model
  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 Disposer Parent { get; set; }
  14. public T GetParent<T>() where T : Disposer
  15. {
  16. return this.Parent as T;
  17. }
  18. public Entity Entity
  19. {
  20. get
  21. {
  22. return this.Parent as Entity;
  23. }
  24. }
  25. public override void Dispose()
  26. {
  27. if (this.IsDisposed)
  28. {
  29. return;
  30. }
  31. base.Dispose();
  32. }
  33. }
  34. }