static WebConfigurationManager()
        {
            configFactory             = ConfigurationManager.ConfigurationFactory;
            _Configuration.SaveStart += ConfigurationSaveHandler;
            _Configuration.SaveEnd   += ConfigurationSaveHandler;

            // Part of fix for bug #491531
            Type type = Type.GetType("System.Configuration.CustomizableFileSettingsProvider, System", false);

            if (type != null)
            {
                FieldInfo fi = type.GetField("webConfigurationFileMapType", BindingFlags.Static | BindingFlags.NonPublic);
                if (fi != null && fi.FieldType == Type.GetType("System.Type"))
                {
                    fi.SetValue(null, typeof(ApplicationSettingsConfigurationFileMap));
                }
            }

            sectionCacheLock = new ReaderWriterLockSlim();
        }
Esempio n. 2
0
        static WebConfigurationManager()
        {
            var  section_cache_size = DEFAULT_SECTION_CACHE_SIZE;
            int  section_cache_size_override;
            bool size_overriden = false;

            if (int.TryParse(Environment.GetEnvironmentVariable(CACHE_SIZE_OVERRIDING_KEY), out section_cache_size_override))
            {
                section_cache_size = section_cache_size_override;
                size_overriden     = true;
                Console.WriteLine("WebConfigurationManager's LRUcache Size overriden to: {0} (via {1})", section_cache_size_override, CACHE_SIZE_OVERRIDING_KEY);
            }
            sectionCache = new LruCache <int, object> (section_cache_size);
            string eviction_warning = "WebConfigurationManager's LRUcache evictions count reached its max size";

            if (!size_overriden)
            {
                eviction_warning += String.Format("{0}Cache Size: {1} (overridable via {2})",
                                                  Environment.NewLine, section_cache_size, CACHE_SIZE_OVERRIDING_KEY);
            }
            sectionCache.EvictionWarning = eviction_warning;

            configFactory             = ConfigurationManager.ConfigurationFactory;
            _Configuration.SaveStart += ConfigurationSaveHandler;
            _Configuration.SaveEnd   += ConfigurationSaveHandler;

            // Part of fix for bug #491531
            Type type = Type.GetType("System.Configuration.CustomizableFileSettingsProvider, System", false);

            if (type != null)
            {
                FieldInfo fi = type.GetField("webConfigurationFileMapType", BindingFlags.Static | BindingFlags.NonPublic);
                if (fi != null && fi.FieldType == Type.GetType("System.Type"))
                {
                    fi.SetValue(null, typeof(ApplicationSettingsConfigurationFileMap));
                }
            }

            sectionCacheLock = new ReaderWriterLockSlim();
        }
Esempio n. 3
0
		static WebConfigurationManager ()
		{
			var section_cache_size = DEFAULT_SECTION_CACHE_SIZE;
			int section_cache_size_override;
			bool size_overriden = false;
			if (int.TryParse (Environment.GetEnvironmentVariable (CACHE_SIZE_OVERRIDING_KEY), out section_cache_size_override)) {
				section_cache_size = section_cache_size_override;
				size_overriden = true;
				Console.WriteLine ("WebConfigurationManager's LRUcache Size overriden to: {0} (via {1})", section_cache_size_override, CACHE_SIZE_OVERRIDING_KEY);
			}
			sectionCache = new LruCache<int, object> (section_cache_size);
			string eviction_warning = "WebConfigurationManager's LRUcache evictions count reached its max size";
			if (!size_overriden)
				eviction_warning += String.Format ("{0}Cache Size: {1} (overridable via {2})",
				                                   Environment.NewLine, section_cache_size, CACHE_SIZE_OVERRIDING_KEY);
			sectionCache.EvictionWarning = eviction_warning;

			configFactory = ConfigurationManager.ConfigurationFactory;
			_Configuration.SaveStart += ConfigurationSaveHandler;
			_Configuration.SaveEnd += ConfigurationSaveHandler;
			
			// Part of fix for bug #491531
			Type type = Type.GetType ("System.Configuration.CustomizableFileSettingsProvider, System", false);
			if (type != null) {
				FieldInfo fi = type.GetField ("webConfigurationFileMapType", BindingFlags.Static | BindingFlags.NonPublic);
				if (fi != null && fi.FieldType == Type.GetType ("System.Type"))
					fi.SetValue (null, typeof (ApplicationSettingsConfigurationFileMap));
			}

			sectionCacheLock = new ReaderWriterLockSlim ();
		}