private bool OverrideWithGroupPolicyTypeTypesAndGenerateWmiObjectsForPolicyType(ExceptionTypeData exceptionType, ExceptionPolicyData parentPolicy, 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 { PostHandlingAction?postHandlingActionOverride = policyKey.GetEnumValue <PostHandlingAction>(PolicyTypePostHandlingActionPropertyName); exceptionType.PostHandlingAction = postHandlingActionOverride.Value; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { ExceptionHandlingSettingsWmiMapper.GenerateExceptionTypeWmiObjects(exceptionType, parentPolicy, wmiSettings); } // Note: store the handler settings to a temporary location to enable // post processing. This forces the creation of a specific interface and // fixes the schema. List <ConfigurationSetting> handlerSettings = new List <ConfigurationSetting>(exceptionType.ExceptionHandlers.Count); OverrideWithGroupPoliciesAndGenerateWmiObjectsForElementCollection(exceptionType.ExceptionHandlers, PolicyTypeHandlersPropertyName, readGroupPolicies, machineKey, userKey, generateWmiObjects, handlerSettings); int i = 0; foreach (ExceptionHandlerSetting setting in handlerSettings) { setting.Policy = parentPolicy.Name; setting.ExceptionType = exceptionType.Name; setting.Order = i++; // add the post-processed handler settings to the main settings collection wmiSettings.Add(setting); } return(true); }
/// <summary> /// Overrides the <paramref name="configurationSection"/>'s configuration elements' properties /// with the Group Policy values from the registry, if any, and creates the <see cref="ConfigurationSetting"/> /// instances that describe these configuration elements. /// </summary> /// <param name="configurationSection">The configuration section that must be managed.</param> /// <param name="readGroupPolicies"><see langword="true"/> if Group Policy overrides must be applied; otherwise, /// <see langword="false"/>.</param> /// <param name="machineKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the /// configuration section at the machine level, or <see langword="null"/> /// if there is no such registry key.</param> /// <param name="userKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the /// configuration section at the user level, or <see langword="null"/> /// if there is no such registry key.</param> /// <param name="generateWmiObjects"><see langword="true"/> if WMI objects must be generated; otherwise, /// <see langword="false"/>.</param> /// <param name="wmiSettings">A collection to where the generated WMI objects are to be added.</param> protected override void OverrideWithGroupPoliciesAndGenerateWmiObjectsForConfigurationElements(ExceptionHandlingSettings configurationSection, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { IRegistryKey machinePoliciesKey = null; IRegistryKey userPoliciesKey = null; try { LoadRegistrySubKeys(PoliciesKeyName, machineKey, userKey, out machinePoliciesKey, out userPoliciesKey); foreach (ExceptionPolicyData policy in configurationSection.ExceptionPolicies) { IRegistryKey machinePolicyKey = null; IRegistryKey userPolicyKey = null; try { LoadRegistrySubKeys(policy.Name, machinePoliciesKey, userPoliciesKey, out machinePolicyKey, out userPolicyKey); OverrideWithGroupPoliciesAndGenerateWmiObjectsForPolicy(policy, readGroupPolicies, machinePolicyKey, userPolicyKey, generateWmiObjects, wmiSettings); if (generateWmiObjects) { ExceptionHandlingSettingsWmiMapper.GenerateExceptionPolicyDataWmiObjects(policy, wmiSettings); } } finally { ReleaseRegistryKeys(machinePolicyKey, userPolicyKey); } } } finally { ReleaseRegistryKeys(machinePoliciesKey, userPoliciesKey); } }
/// <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="ExceptionHandlingSettingsManageabilityProvider"/> class with a /// given set of manageability providers to use when dealing with the configuration for exception handlers. /// </summary> /// <param name="subProviders">The mapping from configuration element type to /// <see cref="ConfigurationElementManageabilityProvider"/>.</param> public ExceptionHandlingSettingsManageabilityProvider(IDictionary <Type, ConfigurationElementManageabilityProvider> subProviders) : base(subProviders) { ExceptionHandlingSettingsWmiMapper.RegisterWmiTypes(); }
/// <summary> /// /// </summary> /// <param name="configurationSection"></param> /// <param name="wmiSettings"></param> protected override void GenerateWmiObjectsForConfigurationSection(ExceptionHandlingSettings configurationSection, ICollection <ConfigurationSetting> wmiSettings) { ExceptionHandlingSettingsWmiMapper.GenerateWmiObjects(configurationSection, wmiSettings); }