Object.cs 660 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.ComponentModel;
  3. using MongoDB.Bson.Serialization.Attributes;
  4. namespace Base
  5. {
  6. public abstract class Object: IDisposable, ISupportInitialize
  7. {
  8. public static ObjectManager ObjectManager = new ObjectManager();
  9. [BsonId]
  10. public long Id { get; private set; }
  11. protected Object()
  12. {
  13. Id = IdGenerater.GenerateId();
  14. }
  15. protected Object(long id)
  16. {
  17. this.Id = id;
  18. }
  19. public bool IsDisposed()
  20. {
  21. return this.Id == 0;
  22. }
  23. public virtual void Dispose()
  24. {
  25. if (this.Id == 0)
  26. {
  27. return;
  28. }
  29. this.Id = 0;
  30. }
  31. public virtual void BeginInit()
  32. {
  33. }
  34. public virtual void EndInit()
  35. {
  36. }
  37. }
  38. }