ComponentWithId.cs 669 B

1234567891011121314151617181920212223242526272829303132333435
  1. 
  2. using MongoDB.Bson.Serialization.Attributes;
  3. namespace KYFramework
  4. {
  5. [BsonIgnoreExtraElements]
  6. public abstract class ComponentWithId : Component
  7. {
  8. [BsonIgnoreIfDefault]
  9. [BsonDefaultValue(0L)]
  10. [BsonElement]
  11. [BsonId]
  12. public long Id { get; set; }
  13. protected ComponentWithId()
  14. {
  15. this.Id = this.InstanceId;
  16. }
  17. protected ComponentWithId(long id)
  18. {
  19. this.Id = id;
  20. }
  21. public override void Dispose()
  22. {
  23. if (this.IsDisposed)
  24. {
  25. return;
  26. }
  27. base.Dispose();
  28. }
  29. }
  30. }