提交 1b879d1e 编写于 作者: T tanghai

想到了更简单的方法,序列化Entity可以忽略Component的Id

上级 129aae93
......@@ -6,10 +6,6 @@ namespace Model
[BsonKnownTypes(typeof(AConfigComponent))]
public abstract class Component: Disposer
{
[BsonId]
[BsonIgnore]
public sealed override long Id { get; set; }
[BsonIgnore]
public Entity Entity { get; set; }
......@@ -20,7 +16,7 @@ namespace Model
protected Component()
{
this.Id = IdGenerater.GenerateId();
this.Id = 1;
}
public T GetComponent<T>() where T : Component
......
......@@ -5,8 +5,10 @@ namespace Model
{
public abstract class Disposer : Object, IDisposable
{
[BsonIgnore]
public abstract long Id { get; set; }
[BsonIgnoreIfDefault]
[BsonDefaultValue(1L)]
[BsonElement]
public long Id { get; set; }
protected Disposer()
{
......
......@@ -9,10 +9,6 @@ namespace Model
[BsonIgnoreExtraElements]
public class Entity : Disposer, ISupportInitialize
{
[BsonId]
[BsonElement(Order = 1)]
public sealed override long Id { get; set; }
[BsonIgnore]
public Entity Parent { get; set; }
......
using Model;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Attributes;
namespace Hotfix
{
public abstract class Component : Disposer
{
[BsonId]
[BsonIgnore]
public sealed override long Id { get; set; }
[BsonIgnore]
public Entity Entity { get; set; }
......@@ -19,7 +14,7 @@ namespace Hotfix
protected Component()
{
this.Id = IdGenerater.GenerateId();
this.Id = 1;
}
public T GetComponent<T>() where T : Component
......
......@@ -4,8 +4,10 @@ namespace Hotfix
{
public abstract class Disposer : Object, IDisposable2
{
[BsonIgnore]
public abstract long Id { get; set; }
[BsonIgnoreIfDefault]
[BsonDefaultValue(1L)]
[BsonElement]
public long Id { get; set; }
protected Disposer()
{
......
......@@ -10,10 +10,6 @@ namespace Hotfix
[BsonIgnoreExtraElements]
public class Entity : Disposer, ISupportInitialize
{
[BsonId]
[BsonElement(Order = 1)]
public sealed override long Id { get; set; }
[BsonIgnore]
public Entity Parent { get; set; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册