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()); BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(ExtraOut), new StructBsonSerialize()); #elif ROBOT BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize()); #else BsonSerializer.RegisterSerializer(typeof (Vector4), new StructBsonSerialize()); BsonSerializer.RegisterSerializer(typeof (Vector3), new StructBsonSerialize()); #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() { } } }