Component.cs 606 字节
Newer Older
1 2
using MongoDB.Bson.Serialization.Attributes;

3
namespace ETModel
4
{
T
tanghai 已提交
5
	[BsonIgnoreExtraElements]
6
	public abstract partial class Component: Disposer
7
	{
T
tanghai 已提交
8 9 10 11 12 13
		[BsonIgnoreIfDefault]
		[BsonDefaultValue(0L)]
		[BsonElement]
		[BsonId]
		public long Id { get; set; }

14
		[BsonIgnore]
15
		public Component Parent { get; set; }
16

17
		public T GetParent<T>() where T : Component
18
		{
19
			return this.Parent as T;
20 21
		}

22
		[BsonIgnore]
T
tanghai 已提交
23 24 25 26 27 28 29 30
		public Entity Entity
		{
			get
			{
				return this.Parent as Entity;
			}
		}

31 32
		public override void Dispose()
		{
T
tanghai 已提交
33
			if (this.IsDisposed)
34 35 36 37 38 39 40 41
			{
				return;
			}

			base.Dispose();
		}
	}
}