|
|
|
using System;
|
|
|
|
using MongoDB.Bson.Serialization;
|
|
|
|
using MongoDB.Bson.Serialization.Conventions;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
{
|
|
|
|
public static class MongoRegister
|
|
|
|
{
|
|
|
|
static MongoRegister()
|
|
|
|
{
|
|
|
|
// 自动注册IgnoreExtraElements
|
|
|
|
|
|
|
|
ConventionPack conventionPack = new ConventionPack { new IgnoreExtraElementsConvention(true) };
|
|
|
|
|
|
|
|
ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true);
|
|
|
|
|
|
|
|
#if SERVER
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Vector2), new StructBsonSerialize<Vector2>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize<Vector3>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize<Vector4>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize<Quaternion>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize<ResourceAttri>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(ExtraOut), new StructBsonSerialize<ExtraOut>());
|
|
|
|
#elif ROBOT
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize<Quaternion>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize<Vector3>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize<Vector4>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize<ResourceAttri>());
|
|
|
|
#else
|
|
|
|
BsonSerializer.RegisterSerializer(typeof (Vector4), new StructBsonSerialize<Vector4>());
|
|
|
|
BsonSerializer.RegisterSerializer(typeof (Vector3), new StructBsonSerialize<Vector3>());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
var types = Game.EventSystem.GetTypes();
|
|
|
|
|
|
|
|
foreach (Type type in types.Values)
|
|
|
|
{
|
|
|
|
if (!type.IsSubclassOf(typeof (Object)))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type.IsGenericType)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
BsonClassMap.LookupClassMap(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|