Пример #1
0
        private void OnSessionFactoryHolderCreated(Castle.ActiveRecord.Framework.ISessionFactoryHolder holder)
        {
            holder.OnRootTypeRegistered += new RootTypeHandler(OnRootTypeRegistered);

            if (!Kernel.HasComponent("activerecord.sessionfactoryholder"))
            {
                Kernel.AddComponentInstance(
                    "activerecord.sessionfactoryholder",
                    typeof(ISessionFactoryHolder), holder);
            }
            else
            {
                sessionFactoryHolderCount++;

                Kernel.AddComponentInstance(
                    "activerecord.sessionfactoryholder." + sessionFactoryCount.ToString(),
                    typeof(ISessionFactoryHolder), holder);
            }
        }
        private void OnSessionFactoryHolderCreated(Castle.ActiveRecord.Framework.ISessionFactoryHolder holder)
        {
            holder.OnRootTypeRegistered += new RootTypeHandler(OnRootTypeRegistered);

            string componentName = "activerecord.sessionfactoryholder";

            if (Kernel.HasComponent(componentName))
            {
                componentName += "." + (++sessionFactoryHolderCount);
            }

            while (Kernel.HasComponent(componentName))
            {
                componentName =
                    componentName.Substring(0, componentName.LastIndexOf('.'))
                    + (++sessionFactoryHolderCount);
            }

            log.Info("Registering SessionFactoryHolder named '{0}': {1}", componentName, holder);

            Kernel.Register(Component.For <ISessionFactoryHolder>().Named(componentName).Instance(holder));
        }