private bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForDbProviderMapping(DbProviderMapping providerMapping,
                                                                                        bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey,
                                                                                        bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings)
        {
            if (readGroupPolicies)
            {
                IRegistryKey policyKey = machineKey ?? userKey;
                if (policyKey != null)
                {
                    if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value)
                    {
                        return(false);
                    }
                    try
                    {
                        Type databaseTypeOverride = policyKey.GetTypeValue(DatabaseTypePropertyName);

                        providerMapping.DatabaseType = databaseTypeOverride;
                    }
                    catch (RegistryAccessException ex)
                    {
                        LogExceptionWhileOverriding(ex);
                    }
                }
            }
            if (generateWmiObjects)
            {
                DatabaseSettingsWmiMapper.GenerateDbProviderMappingWmiObjects(providerMapping, wmiSettings);
            }

            return(true);
        }
コード例 #2
0
 /// <summary>
 /// Saves the changes on the <see cref="ProviderMappingSetting"/> to its corresponding configuration object.
 /// </summary>
 /// <param name="sourceElement">The configuration object on which the changes must be saved.</param>
 /// <returns><see langword="true"/> if changes have been saved, <see langword="false"/> otherwise.</returns>
 protected override bool SaveChanges(ConfigurationElement sourceElement)
 {
     return(DatabaseSettingsWmiMapper.SaveChanges(this, sourceElement));
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="DatabaseSettingsManageabilityProvider"/> class with the sub providers.
 /// </summary>
 /// <param name="subProviders">A set of sub providers.</param>
 public DatabaseSettingsManageabilityProvider(IDictionary <Type, ConfigurationElementManageabilityProvider> subProviders)
     : base(subProviders)
 {
     DatabaseSettingsWmiMapper.RegisterWmiTypes();
 }
 /// <summary>
 /// Creates the <see cref="ConfigurationSetting"/> instances that describe the <paramref name="configurationSection"/>.
 /// </summary>
 /// <param name="configurationSection">The configuration section that must be managed.</param>
 /// <param name="wmiSettings">A collection to where the generated WMI objects are to be added.</param>
 protected override void GenerateWmiObjectsForConfigurationSection(DatabaseSettings configurationSection,
                                                                   ICollection <ConfigurationSetting> wmiSettings)
 {
     DatabaseSettingsWmiMapper.GenerateWmiObjects(configurationSection, wmiSettings);
 }