public void Register() { // It should not fire an exception MongoDbSerialization.Register(typeof(DerivedClass)); //var type = typeof(DerivedClass); //if (BsonClassMap.IsClassMapRegistered(type)) // return; //var cm = new BsonClassMap(type); //cm.AutoMap(); //BsonClassMap.RegisterClassMap(cm); }
private static void SetupSerialization() { ConventionRegistry.Register( nameof(ImmutablePocoConvention), new ConventionPack { new ImmutablePocoConvention() }, t => typeof(IEvent).IsAssignableFrom(t)); var events = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(p => p.GetTypes()) .Where(p => typeof(IEvent).IsAssignableFrom(p) && p.IsClass && !p.IsAbstract); foreach (var e in events) { MongoDbSerialization.Register(e); } }
public void GetDiscriminatorName(string exceptedName, Type type) { Assert.Equal(exceptedName, MongoDbSerialization.GetDiscriminatorName(type)); }