コード例 #1
0
        /// <summary>
        /// Initializes the <see cref="SysCacheProvider"/> class.
        /// </summary>
        static SysCacheProvider()
        {
            Log = NHibernateLogger.For(typeof(SysCacheProvider));
            // We need to determine which cache regions are configured in the configuration file, but we cant create the
            // cache regions at this time because there could be nhibernate configuration values
            // that we need for the cache regions such as connection info to be used for data dependencies. But this info
            // isn't available until build cache is called. So allocate space but only create them on demand.

            var configSection = SysCacheSection.GetSection();

            if (configSection != null && configSection.CacheRegions.Count > 0)
            {
                CacheRegionSettings = new Dictionary <string, CacheRegionElement>(configSection.CacheRegions.Count);
                foreach (var cacheRegion in configSection.CacheRegions)
                {
                    if (cacheRegion is CacheRegionElement element)
                    {
                        CacheRegionSettings.Add(element.Name, element);
                    }
                }
            }
            else
            {
                CacheRegionSettings = new Dictionary <string, CacheRegionElement>(0);
                Log.Info(
                    "No cache regions specified. Cache regions can be specified in sysCache configuration section with custom settings.");
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes the <see cref="SysCacheProvider"/> class.
        /// </summary>
        static SysCacheProvider()
        {
            //we need to determine which cache regions are configured in the configuration file, but we cant create the
            //cache regions at this time becasue there could be nhibernate configuration values
            //that we need for the cache regions such as connection info to be used for data dependencies, but this info
            //isnt available until until build cache is called.  So allocte space but only create them on demand

            SysCacheSection configSection = SysCacheSection.GetSection();

            if (configSection != null && configSection.CacheRegions.Count > 0)
            {
                cacheRegionSettingsList = configSection.CacheRegions;
                cacheRegions            = new Dictionary <string, SysCacheRegion>(cacheRegionSettingsList.Count);
            }
            else
            {
                cacheRegions = new Dictionary <string, SysCacheRegion>(0);
                log.Info(
                    "No cache regions specified. Cache regions can be specified in sysCache configuration section with custom settings.");
            }
        }