bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForCacheManager(CacheManagerDataBase cacheManagerDataBase,
                                                                           bool readGroupPolicies,
                                                                           IRegistryKey machineKey,
                                                                           IRegistryKey userKey,
                                                                           bool generateWmiObjects,
                                                                           ICollection <ConfigurationSetting> wmiSettings)
        {
            if (readGroupPolicies)
            {
                IRegistryKey policyKey = machineKey != null ? machineKey : userKey;
                if (policyKey != null)
                {
                    if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value)
                    {
                        return(false);
                    }
                    try
                    {
                        if (cacheManagerDataBase is CacheManagerData)
                        {
                            CacheManagerData cacheManagerData = (CacheManagerData)cacheManagerDataBase;

                            // cache storage is not overrideable
                            int?expirationPollFrequencyInSecondsOverride
                                = policyKey.GetIntValue(CacheManagerExpirationPollFrequencyInSecondsPropertyName);
                            int?maximumElementsInCacheBeforeScavengingOverride
                                = policyKey.GetIntValue(CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName);
                            int?numberToRemoveWhenScavengingOverride
                                = policyKey.GetIntValue(CacheManagerNumberToRemoveWhenScavengingPropertyName);

                            cacheManagerData.ExpirationPollFrequencyInSeconds       = expirationPollFrequencyInSecondsOverride.Value;
                            cacheManagerData.MaximumElementsInCacheBeforeScavenging = maximumElementsInCacheBeforeScavengingOverride.Value;
                            cacheManagerData.NumberToRemoveWhenScavenging           = numberToRemoveWhenScavengingOverride.Value;
                        }
                    }
                    catch (RegistryAccessException ex)
                    {
                        LogExceptionWhileOverriding(ex);
                    }
                }
            }
            if (generateWmiObjects)
            {
                CacheManagerSettingsWmiMapper.GenerateCacheManagerWmiObjects(cacheManagerDataBase, wmiSettings);
            }

            return(true);
        }
 protected override bool SaveChanges(ConfigurationElement sourceElement)
 {
     return(CacheManagerSettingsWmiMapper.SaveChanges(this, sourceElement));
 }
 /// <summary>
 /// <para>This method supports the Enterprise Library Manageability Extensions infrastructure and is not intended to
 /// be used directly from your code.
 /// </para>
 /// Initializes a new instance of the <see cref="CacheManagerSettingsManageabilityProvider"/> class with a
 /// given set of manageability providers to use when dealing with the configuration for cache storage and encryption providers.
 /// </summary>
 /// <param name="subProviders">The mapping from configuration element type to
 /// <see cref="ConfigurationElementManageabilityProvider"/>.</param>
 public CacheManagerSettingsManageabilityProvider(IDictionary <Type, ConfigurationElementManageabilityProvider> subProviders)
     : base(subProviders)
 {
     CacheManagerSettingsWmiMapper.RegisterWmiTypes();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="configurationSection"></param>
 /// <param name="wmiSettings"></param>
 protected override void GenerateWmiObjectsForConfigurationSection(CacheManagerSettings configurationSection,
                                                                   ICollection <ConfigurationSetting> wmiSettings)
 {
     CacheManagerSettingsWmiMapper.GenerateWmiObjects(configurationSection, wmiSettings);
 }