Exemplo n.º 1
0
        private static void RaiseSessionFactoryHolderCreated(ISessionFactoryHolder holder)
        {
            SessionFactoryHolderDelegate evtDelegate =
                (SessionFactoryHolderDelegate)events[SessionFactoryHolderCreatedEvent];

            if (evtDelegate != null)
            {
                evtDelegate(holder);
            }
        }
Exemplo n.º 2
0
        private static void RegisterTypes(ISessionFactoryHolder holder, IConfigurationSource source, IEnumerable <Type> types,
                                          bool ignoreProblematicTypes)
        {
            lock (lockConfig)
            {
                ActiveRecordModelCollection models = BuildModels(holder, source, types, ignoreProblematicTypes);

                GraphConnectorVisitor connectorVisitor = new GraphConnectorVisitor(models);
                connectorVisitor.VisitNodes(models);

                ModelsDelegate modelsCreatedHandler = ModelsCreated;
                if (modelsCreatedHandler != null)
                {
                    modelsCreatedHandler(models, source);
                }

                SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(models);
                semanticVisitor.VisitNodes(models);

                ModelsDelegate modelsValidatedHandler = ModelsValidated;
                if (modelsValidatedHandler != null)
                {
                    modelsValidatedHandler(models, source);
                }

                AddXmlToNHibernateCfg(holder, models);

                AddXmlToNHibernateFromAssmebliesAttributes(holder, models);

                SessionFactoryHolderDelegate registeredInConfigurationHandler = MappingRegisteredInConfiguration;
                if (registeredInConfigurationHandler != null)
                {
                    registeredInConfigurationHandler(holder);
                }

                if (source.VerifyModelsAgainstDBSchema)
                {
                    VerifySchema(models);
                }
            }
        }
Exemplo n.º 3
0
        private void CallInitializationAwareConfigureIfExists()
        {
            SessionFactoryHolderDelegate holderDelegate = null;

            holderDelegate = delegate(ISessionFactoryHolder holder)
            {
                ActiveRecordStarter.MappingRegisteredInConfiguration -= holderDelegate;
                if (IoC.IsInitialized && IoC.Container.Kernel.HasComponent(typeof(INHibernateInitializationAware)))
                {
                    INHibernateInitializationAware[] initializationAware = IoC.ResolveAll <INHibernateInitializationAware>();
                    if (initializationAware != null)
                    {
                        foreach (Configuration configuration in holder.GetAllConfigurations())
                        {
                            foreach (INHibernateInitializationAware initializer in initializationAware)
                            {
                                initializer.Configured(configuration);
                            }
                        }
                    }
                }
            };
            ActiveRecordStarter.MappingRegisteredInConfiguration += holderDelegate;
        }