コード例 #1
0
        /// <summary>
        /// Initialize current facility
        /// </summary>
        protected override void Init() {
            if(IsDebugEnabled)
                log.Debug("Multiple UnitOfWork를 위한 Facility를 초기화 합니다.");

            Kernel.Register(Component.For(typeof(INHRepository<>)).ImplementedBy(typeof(NHRepository<>)));

            var multipleUowFactory = new NHMultipleUnitOfWorkFactory();

            if(_configs == null) {
                if(IsDebugEnabled)
                    log.Debug("프로그램에서 지정한 환경설정 정보가 없으므로, 환경설정 파일에서 정보를 얻습니다.");

                AssertConfigurations();
                _configs = FacilityConfig.Children.Select(factoryConfig => new NHUnitOfWorkFacilityConfig(factoryConfig)).ToArray();
                multipleUowFactory.DefaultFactoryName = _defaultFactoryName;
            }

            if(IsDebugEnabled)
                log.Debug("환경설정에 지정된 Factory 정보로부터, NHUnitOfWorkFactory를 생성합니다.");

            foreach(NHUnitOfWorkFacilityConfig config in _configs) {
                var nestedUnitOfWorkFactory = new NHUnitOfWorkFactory(config.NHibernateConfigurationFilename);
                nestedUnitOfWorkFactory.RegisterSessionFactory(CreateSessionFactory(config));
                multipleUowFactory.Add(nestedUnitOfWorkFactory);
            }

            Kernel.Register(Component.For<IUnitOfWorkFactory>().Instance(multipleUowFactory));
            // Kernel.AddComponentInstance<IUnitOfWorkFactory>(multipleUowFactory);

            if(IsDebugEnabled)
                log.Debug("Kernel에 NHMultipleUnitOfWorkFactory의 인스턴스를 등록했습니다.");
        }
コード例 #2
0
        /// <summary>
        /// Initialize current facility
        /// </summary>
        protected override void Init()
        {
            if (IsDebugEnabled)
            {
                log.Debug("Multiple UnitOfWork를 위한 Facility를 초기화 합니다.");
            }

            Kernel.Register(Component.For(typeof(INHRepository <>)).ImplementedBy(typeof(NHRepository <>)));

            var multipleUowFactory = new NHMultipleUnitOfWorkFactory();

            if (_configs == null)
            {
                if (IsDebugEnabled)
                {
                    log.Debug("프로그램에서 지정한 환경설정 정보가 없으므로, 환경설정 파일에서 정보를 얻습니다.");
                }

                AssertConfigurations();
                _configs = FacilityConfig.Children.Select(factoryConfig => new NHUnitOfWorkFacilityConfig(factoryConfig)).ToArray();
                multipleUowFactory.DefaultFactoryName = _defaultFactoryName;
            }

            if (IsDebugEnabled)
            {
                log.Debug("환경설정에 지정된 Factory 정보로부터, NHUnitOfWorkFactory를 생성합니다.");
            }

            foreach (NHUnitOfWorkFacilityConfig config in _configs)
            {
                var nestedUnitOfWorkFactory = new NHUnitOfWorkFactory(config.NHibernateConfigurationFilename);
                nestedUnitOfWorkFactory.RegisterSessionFactory(CreateSessionFactory(config));
                multipleUowFactory.Add(nestedUnitOfWorkFactory);
            }

            Kernel.Register(Component.For <IUnitOfWorkFactory>().Instance(multipleUowFactory));
            // Kernel.AddComponentInstance<IUnitOfWorkFactory>(multipleUowFactory);

            if (IsDebugEnabled)
            {
                log.Debug("Kernel에 NHMultipleUnitOfWorkFactory의 인스턴스를 등록했습니다.");
            }
        }