private static void UpdateCacheMultiple(NConfigRootReplacement rootReplacement, string configPath, object cacheInternal) { var cacheMultiple = new ReflectionAccessor(cacheInternal); var caches = cacheMultiple.GetField("_caches") as IEnumerable ?? Enumerable.Empty <object>(); foreach (var cache in caches) { // Caches stored in array ala hash, so there are could be gaps. if (cache == null) { continue; } UpdateCacheSingle(rootReplacement, cache, configPath); } //Private field from System.Web.Caching.CacheMultiple used to be called _caches but can also be called _cachesRefs var cacheRefs = cacheMultiple.GetField("_cachesRefs") as IEnumerable ?? Enumerable.Empty <object>(); foreach (var cacheRef in cacheRefs) { if (cacheRef == null) { continue; } var cacheAcessor = new ReflectionAccessor(cacheRef); var cache = cacheAcessor.GetProperty("Target"); if (cache != null) { UpdateCacheSingle(rootReplacement, cache, configPath); } } }
private static void UpdateCacheSingle(NConfigRootReplacement rootReplacement, object cache, string configPath) { var cacheAcessor = new ReflectionAccessor(cache); lock (cacheAcessor.GetField("_lock")) { var entries = cacheAcessor.GetField("_entries") as IEnumerable ?? Enumerable.Empty<object>(); // Get all site specific configuration records keys for internal cache. // cache "entries" is a HashTable, so just iterate through foreach (DictionaryEntry entry in entries) { var keyAccessor = new ReflectionAccessor(entry.Key); // Only configuration cache entries replaced. if (!keyAccessor.GetProperty("Key").ToString().StartsWith(configPath)) continue; // Key and Value is the same object in the configuration cache entry. var entryValueAccesor = new ReflectionAccessor(keyAccessor.GetField("_value")); var runtimeConfigAccessor = new ReflectionAccessor(entryValueAccesor.GetField("_runtimeConfig")); IInternalConfigRecord replacingRecord = rootReplacement.CreateConfigRecord(runtimeConfigAccessor.GetField<IInternalConfigRecord>("_configRecord")); runtimeConfigAccessor.SetField("_configRecord", replacingRecord); runtimeConfigAccessor.SetField("_runtimeConfigLKG", null); } } }
private static void UpdateCacheSingle(NConfigRootReplacement rootReplacement, object cache, string configPath) { var cacheAcessor = new ReflectionAccessor(cache); lock (cacheAcessor.GetField("_lock")) { var entries = cacheAcessor.GetField("_entries") as IEnumerable ?? Enumerable.Empty <object>(); // Get all site specific configuration records keys for internal cache. // cache "entries" is a HashTable, so just iterate through foreach (DictionaryEntry entry in entries) { var keyAccessor = new ReflectionAccessor(entry.Key); // Only configuration cache entries replaced. if (!keyAccessor.GetProperty("Key").ToString().StartsWith(configPath)) { continue; } // Key and Value is the same object in the configuration cache entry. var entryValueAccesor = new ReflectionAccessor(keyAccessor.GetField("_value")); var runtimeConfigAccessor = new ReflectionAccessor(entryValueAccesor.GetField("_runtimeConfig")); IInternalConfigRecord replacingRecord = rootReplacement.CreateConfigRecord(runtimeConfigAccessor.GetField <IInternalConfigRecord>("_configRecord")); runtimeConfigAccessor.SetField("_configRecord", replacingRecord); runtimeConfigAccessor.SetField("_runtimeConfigLKG", null); } } }
private static void UpdateCacheMultiple(NConfigRootReplacement rootReplacement, string configPath, object cacheInternal) { var cacheMultiple = new ReflectionAccessor(cacheInternal); var caches = cacheMultiple.GetField("_caches") as IEnumerable ?? Enumerable.Empty<object>(); foreach (var cache in caches) { // Caches stored in array ala hash, so there are could be gaps. if (cache == null) continue; UpdateCacheSingle(rootReplacement, cache, configPath); } //Private field from System.Web.Caching.CacheMultiple used to be called _caches but can also be called _cachesRefs var cacheRefs = cacheMultiple.GetField("_cachesRefs") as IEnumerable ?? Enumerable.Empty<object>(); foreach (var cacheRef in cacheRefs) { if (cacheRef == null) continue; var cacheAcessor = new ReflectionAccessor(cacheRef); var cache = cacheAcessor.GetProperty("Target"); if (cache != null) UpdateCacheSingle(rootReplacement, cache, configPath); } }
private static void UpdateCacheMultiple(NConfigRootReplacement rootReplacement, string configPath, object cacheInternal) { var cacheMultiple = new ReflectionAccessor(cacheInternal); var caches = cacheMultiple.GetField("_caches") as IEnumerable ?? Enumerable.Empty<object>(); foreach (var cache in caches) { // Caches stored in array ala hash, so there are could be gaps. if (cache == null) continue; UpdateCacheSingle(rootReplacement, cache, configPath); } }
private static void UpdateCacheMultiple(NConfigRootReplacement rootReplacement, string configPath, object cacheInternal) { var cacheMultiple = new ReflectionAccessor(cacheInternal); var caches = cacheMultiple.GetField("_caches") as IEnumerable ?? Enumerable.Empty <object>(); foreach (var cache in caches) { // Caches stored in array ala hash, so there are could be gaps. if (cache == null) { continue; } UpdateCacheSingle(rootReplacement, cache, configPath); } }
public NConfigSystemReplacement(IConfigSystem originalConfigSystem, IConfigurationFactory factory, IList<string> fileNames) { this.originalConfigSystem = originalConfigSystem; replacedRoot = new NConfigRootReplacement(originalConfigSystem.Root, factory, fileNames); }
public NConfigSystemReplacement(IConfigSystem originalConfigSystem, IConfigurationFactory factory, IList <string> fileNames) { this.originalConfigSystem = originalConfigSystem; replacedRoot = new NConfigRootReplacement(originalConfigSystem.Root, factory, fileNames); }