| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using MongoDB.Bson.Serialization.Attributes;
- namespace Model
- {
- [BsonKnownTypes(typeof(Entity))]
- [BsonKnownTypes(typeof(Component))]
- public abstract class Disposer : Object, IDisposable
- {
- [BsonIgnoreIfDefault]
- [BsonDefaultValue(1L)]
- [BsonElement]
- [BsonId]
- public long Id { get; set; }
- [BsonIgnore]
- public bool IsFromPool { get; set; }
-
- protected Disposer()
- {
- this.Id = IdGenerater.GenerateId();
- }
- protected Disposer(long id)
- {
- this.Id = id;
- }
- public virtual void Dispose()
- {
- this.Id = 0;
- if (this.IsFromPool)
- {
- ObjectPool.Instance.Recycle(this);
- }
- }
- }
- }
|