void OverrideWithGroupPoliciesForCacheManagers(NamedElementCollection <CacheManagerDataBase> cacheManagers, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { List <CacheManagerDataBase> elementsToRemove = new List <CacheManagerDataBase>(); IRegistryKey machineCacheManagersKey = null; IRegistryKey userCacheManagersKey = null; try { LoadRegistrySubKeys(CacheManagersKeyName, machineKey, userKey, out machineCacheManagersKey, out userCacheManagersKey); foreach (CacheManagerDataBase data in cacheManagers) { IRegistryKey machineCacheManagerKey = null; IRegistryKey userCacheManagerKey = null; try { LoadRegistrySubKeys(data.Name, machineCacheManagersKey, userCacheManagersKey, out machineCacheManagerKey, out userCacheManagerKey); if (data is CustomCacheManagerData) { if (!customManageabilityProvider. OverrideWithGroupPolicies(data, readGroupPolicies, machineCacheManagerKey, userCacheManagerKey)) { elementsToRemove.Add(data); } } else { if (!OverrideWithGroupPoliciesAndGenerateWmiObjectsForCacheManager(data, readGroupPolicies, machineCacheManagerKey, userCacheManagerKey)) { elementsToRemove.Add(data); } } } finally { ReleaseRegistryKeys(machineCacheManagerKey, userCacheManagerKey); } } } finally { ReleaseRegistryKeys(machineCacheManagersKey, userCacheManagersKey); } foreach (CacheManagerDataBase data in elementsToRemove) { cacheManagers.Remove(data.Name); } }
protected void OverrideWithGroupPoliciesAndGenerateWmiObjectsForElementCollection <T>(NamedElementCollection <T> elements, String keyName, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) where T : NamedConfigurationElement, new() { List <T> elementsToRemove = new List <T>(); IRegistryKey machineElementsKey = null; IRegistryKey userElementsKey = null; try { LoadRegistrySubKeys(keyName, machineKey, userKey, out machineElementsKey, out userElementsKey); foreach (T element in elements) { IRegistryKey machineElementKey = null; IRegistryKey userElementKey = null; try { LoadRegistrySubKeys(element.Name, machineElementsKey, userElementsKey, out machineElementKey, out userElementKey); ConfigurationElementManageabilityProvider subProvider = GetSubProvider(element.GetType()); if (subProvider != null && !OverrideWithGroupPoliciesAndGenerateWmiObjectsForElement <T>(element, subProvider, readGroupPolicies, machineElementKey, userElementKey, generateWmiObjects, wmiSettings)) { elementsToRemove.Add(element); } } finally { ReleaseRegistryKeys(machineElementKey, userElementKey); } } } finally { ReleaseRegistryKeys(machineElementsKey, userElementsKey); } // remove disabled elements foreach (T element in elementsToRemove) { elements.Remove(element.Name); } }
private void OverrideWithGroupPoliciesAndGenerateWmiObjectsForCacheManagers(NamedElementCollection <CacheManagerData> cacheManagers, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { List <CacheManagerData> elementsToRemove = new List <CacheManagerData>(); IRegistryKey machineCacheManagersKey = null; IRegistryKey userCacheManagersKey = null; try { LoadRegistrySubKeys(CacheManagersKeyName, machineKey, userKey, out machineCacheManagersKey, out userCacheManagersKey); foreach (CacheManagerData data in cacheManagers) { IRegistryKey machineCacheManagerKey = null; IRegistryKey userCacheManagerKey = null; try { LoadRegistrySubKeys(data.Name, machineCacheManagersKey, userCacheManagersKey, out machineCacheManagerKey, out userCacheManagerKey); if (!OverrideWithGroupPoliciesAndGenerateWmiObjectsForCacheManager(data, readGroupPolicies, machineCacheManagerKey, userCacheManagerKey, generateWmiObjects, wmiSettings)) { elementsToRemove.Add(data); } } finally { ReleaseRegistryKeys(machineCacheManagerKey, userCacheManagerKey); } } } finally { ReleaseRegistryKeys(machineCacheManagersKey, userCacheManagersKey); } foreach (CacheManagerData data in elementsToRemove) { cacheManagers.Remove(data.Name); } }