Object.cs 675 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. [BsonIgnore]
  9. public static ObjectManager ObjectManager = new ObjectManager();
  10. [BsonId]
  11. public long Id { get; private set; }
  12. protected Object()
  13. {
  14. Id = IdGenerater.GenerateId();
  15. }
  16. protected Object(long id)
  17. {
  18. this.Id = id;
  19. }
  20. public bool IsDisposed()
  21. {
  22. return this.Id == 0;
  23. }
  24. public virtual void Dispose()
  25. {
  26. if (this.Id == 0)
  27. {
  28. return;
  29. }
  30. this.Id = 0;
  31. }
  32. public virtual void BeginInit()
  33. {
  34. }
  35. public virtual void EndInit()
  36. {
  37. }
  38. }
  39. }