Ejemplo n.º 1
0
        private void MapEntities()
        {
            var entityTypes = AppDomain.CurrentDomain.GetAssemblies()
                              .SelectMany(a => a.GetTypes().Where(a => a.IsSubclassOf(typeof(Node))));

            foreach (var type in entityTypes)
            {
                var constructor = type.GetConstructor(System.Reflection.BindingFlags.Instance |
                                                      System.Reflection.BindingFlags.NonPublic,
                                                      null, new Type[] { typeof(Mediator), typeof(bool) }, null);
                var map = new BsonClassMap(type);
                map.AutoMap();
                map.SetCreator(() => constructor.Invoke(new object[] { this, true }));
                BsonClassMap.RegisterClassMap(map);
            }
        }