Exemplo n.º 1
0
        private ConfigurationManager()
        {
            string appID = System.Configuration.ConfigurationManager.AppSettings["ncache.application_id"];

            if (string.IsNullOrEmpty(appID))
            {
                throw new ConfigurationException("ncache.application-id not specified in app.config/web.config file");
            }

            string configFilePath = this.GetFilePath("NCacheNHibernate.xml");



            ConfigurationBuilder configBuilder = new ConfigurationBuilder(configFilePath);

            configBuilder.RegisterRootConfigurationObject(typeof(ApplicationConfiguration));
            configBuilder.ReadConfiguration();

            Object[] configuration = configBuilder.Configuration;

            bool appConfigFound = false;

            if (configuration != null && configuration.Length > 0)
            {
                for (int i = 0; i < configuration.Length; i++)
                {
                    _appConfig = configuration[i] as ApplicationConfiguration;
                    if (_appConfig != null)
                    {
                        if (!string.IsNullOrEmpty(_appConfig.ApplicationID) && _appConfig.ApplicationID.ToLower() == appID.ToLower())
                        {
                            appConfigFound = true;
                            break;
                        }
                    }
                }
            }

            if (!appConfigFound)
            {
                throw new ConfigurationException("Invalid value of NCache.application_id. Applicaion configuration not found for application-id = " + appID);
            }
            if (string.IsNullOrEmpty(_appConfig.DefaultRegion))
            {
                throw new Alachisoft.NCache.Runtime.Exceptions.ConfigurationException("default-region cannot be null for application-id = " + _appConfig.ApplicationID);
            }

            _regionConfigManager = new RegionConfigurationManager(_appConfig.CacheRegions);
            if (!_regionConfigManager.Contains(_appConfig.DefaultRegion))
            {
                throw new Alachisoft.NCache.Runtime.Exceptions.ConfigurationException("Region's configuration not specified for default-region : " + _appConfig.DefaultRegion);
            }
        }
Exemplo n.º 2
0
        private ConfigurationManager()
        {


            string appID = System.Configuration.ConfigurationManager.AppSettings["ncache.application_id"];
            if(string.IsNullOrEmpty(appID))
                throw new ConfigurationException("ncache.application-id not specified in app.config/web.config file");

            string configFilePath = this.GetFilePath("NCacheNHibernate.xml");



            ConfigurationBuilder configBuilder = new ConfigurationBuilder(configFilePath);
            configBuilder.RegisterRootConfigurationObject(typeof(ApplicationConfiguration));
            configBuilder.ReadConfiguration();

            Object[] configuration = configBuilder.Configuration;

            bool appConfigFound = false;
            if (configuration != null && configuration.Length > 0)
            {
                for (int i = 0; i < configuration.Length; i++)
                {
                    _appConfig = configuration[i] as ApplicationConfiguration;
                    if(_appConfig!=null)
                    if (!string.IsNullOrEmpty(_appConfig.ApplicationID) && _appConfig.ApplicationID.ToLower() == appID.ToLower())
                    {
                        appConfigFound = true;
                        break;
                    }
                }
            }
            
            if (!appConfigFound)
                throw new ConfigurationException("Invalid value of NCache.application_id. Applicaion configuration not found for application-id = " + appID);
            if (string.IsNullOrEmpty(_appConfig.DefaultRegion))
                throw new Alachisoft.NCache.Runtime.Exceptions.ConfigurationException("default-region cannot be null for application-id = " + _appConfig.ApplicationID);
            
            _regionConfigManager = new RegionConfigurationManager(_appConfig.CacheRegions);
            if (!_regionConfigManager.Contains(_appConfig.DefaultRegion))

                throw new Alachisoft.NCache.Runtime.Exceptions.ConfigurationException("Region's configuration not specified for default-region : "+_appConfig.DefaultRegion);

        }