/// <summary>
        /// <para>Saves the configuration settings created for the application.</para>
        /// </summary>
        /// <param name="serviceProvider">
        /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para>
        /// </param>
        public void Save(IServiceProvider serviceProvider)
        {
            ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);

            if (configurationContext.IsValidSection(ExceptionHandlingSettings.SectionName))
            {
                ExceptionHandlingSettingsNode exceptionHandlingSettingsNode = null;
                try
                {
                    IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
                    exceptionHandlingSettingsNode = hierarchy.FindNodeByType(typeof(ExceptionHandlingSettingsNode)) as ExceptionHandlingSettingsNode;
                    if (exceptionHandlingSettingsNode == null)
                    {
                        return;
                    }
                    ExceptionHandlingSettings exceptionHandlingSettings = exceptionHandlingSettingsNode.ExceptionHandlingSettings;
                    configurationContext.WriteConfiguration(ExceptionHandlingSettings.SectionName, exceptionHandlingSettings);
                }
                catch (ConfigurationException e)
                {
                    ServiceHelper.LogError(serviceProvider, exceptionHandlingSettingsNode, e);
                }
                catch (InvalidOperationException e)
                {
                    ServiceHelper.LogError(serviceProvider, exceptionHandlingSettingsNode, e);
                }
            }
        }
		private void BuildExceptionPolicyNode(ExceptionHandlingSettingsNode node, ExceptionPolicyData policyData)
		{
			ExceptionPolicyNode policyNode = new ExceptionPolicyNode(policyData);
			node.AddNode(policyNode);
			foreach (ExceptionTypeData exceptionTypeData in policyData.ExceptionTypes)
			{
				BuildExceptionTypeNode(policyNode, exceptionTypeData);
			}			
		}
		public ExceptionHandlingSettingsNode Build()
		{
			ExceptionHandlingSettingsNode node = new ExceptionHandlingSettingsNode();			
			foreach (ExceptionPolicyData policyData in settings.ExceptionPolicies)
			{
				BuildExceptionPolicyNode(node, policyData);
			}			
			return node;
		}		
示例#4
0
        private void BuildExceptionPolicyNode(ExceptionHandlingSettingsNode node, ExceptionPolicyData policyData)
        {
            ExceptionPolicyNode policyNode = new ExceptionPolicyNode(policyData);

            node.AddNode(policyNode);
            foreach (ExceptionTypeData exceptionTypeData in policyData.ExceptionTypes)
            {
                BuildExceptionTypeNode(policyNode, exceptionTypeData);
            }
        }
        /// <summary>
        /// <para>Adds to the dictionary configuration data for
        /// the enterpriselibrary.configurationSettings configuration section.</para>
        /// </summary>
        /// <param name="serviceProvider">
        /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para>
        /// </param>
        /// <param name="configurationDictionary">
        /// <para>A <see cref="ConfigurationDictionary"/> to add
        /// configuration data to.</para></param>
        public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary)
        {
            ExceptionHandlingSettingsNode node = GetExceptionHandlingSettingsNode(serviceProvider);

            if (node != null)
            {
                ExceptionHandlingSettings settings = node.ExceptionHandlingSettings;
                configurationDictionary[ExceptionHandlingSettings.SectionName] = settings;
            }
        }
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         ExceptionHandlingSettingsNodeBuilder builder = new ExceptionHandlingSettingsNodeBuilder(serviceProvider, (ExceptionHandlingSettings)section);
         ExceptionHandlingSettingsNode        node    = builder.Build();
         SetProtectionProvider(section, node);
         rootNode.AddNode(node);
     }
 }
        public ExceptionHandlingSettingsNode Build()
        {
            ExceptionHandlingSettingsNode node = new ExceptionHandlingSettingsNode();

            foreach (ExceptionPolicyData policyData in settings.ExceptionPolicies)
            {
                BuildExceptionPolicyNode(node, policyData);
            }
            return(node);
        }
示例#8
0
        public ExceptionHandlingSettingsNode Build()
        {
            ExceptionHandlingSettingsNode node = new ExceptionHandlingSettingsNode();

            foreach (ExceptionPolicyData policyData in settings.ExceptionPolicies)
            {
                BuildExceptionPolicyNode(node, policyData);
            }
            node.RequirePermission = settings.SectionInformation.RequirePermission;
            return(node);
        }
 /// <summary>
 /// <para>Opens the configuration settings and registers them with the application.</para>
 /// </summary>
 /// <param name="serviceProvider">
 /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para>
 /// </param>
 public void Open(IServiceProvider serviceProvider)
 {
     ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);
     if (configurationContext.IsValidSection(ExceptionHandlingSettings.SectionName))
     {
         ExceptionHandlingSettings exceptionHandlingSettings = null;
         ExceptionHandlingSettingsNode exceptionHandlingSettingsNode = null;
         try
         {
             exceptionHandlingSettings = (ExceptionHandlingSettings)configurationContext.GetConfiguration(ExceptionHandlingSettings.SectionName);
             exceptionHandlingSettingsNode = new ExceptionHandlingSettingsNode(exceptionHandlingSettings);
             ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
             configurationNode.Nodes.Add(exceptionHandlingSettingsNode);
         }
         catch (ConfigurationException e)
         {
             ServiceHelper.LogError(serviceProvider, exceptionHandlingSettingsNode, e);
         }
     }
 }
        /// <summary>
        /// <para>Opens the configuration settings and registers them with the application.</para>
        /// </summary>
        /// <param name="serviceProvider">
        /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para>
        /// </param>
        public void Open(IServiceProvider serviceProvider)
        {
            ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);

            if (configurationContext.IsValidSection(ExceptionHandlingSettings.SectionName))
            {
                ExceptionHandlingSettings     exceptionHandlingSettings     = null;
                ExceptionHandlingSettingsNode exceptionHandlingSettingsNode = null;
                try
                {
                    exceptionHandlingSettings     = (ExceptionHandlingSettings)configurationContext.GetConfiguration(ExceptionHandlingSettings.SectionName);
                    exceptionHandlingSettingsNode = new ExceptionHandlingSettingsNode(exceptionHandlingSettings);
                    ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
                    configurationNode.Nodes.Add(exceptionHandlingSettingsNode);
                }
                catch (ConfigurationException e)
                {
                    ServiceHelper.LogError(serviceProvider, exceptionHandlingSettingsNode, e);
                }
            }
        }
示例#11
0
        /// <summary>
        /// Gets the a <see cref="ConfigurationSectionInfo"/> for the exception handling settings configuration section.
        /// </summary>
        /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
        /// <returns>A <see cref="ConfigurationSectionInfo"/> for the exception handling settings configuration section.</returns>
        protected override ConfigurationSectionInfo GetConfigurationSectionInfo(IServiceProvider serviceProvider)
        {
            ConfigurationNode             rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
            ExceptionHandlingSettingsNode node     = null;

            if (null != rootNode)
            {
                node = rootNode.Hierarchy.FindNodeByType(rootNode, typeof(ExceptionHandlingSettingsNode)) as ExceptionHandlingSettingsNode;
            }
            ExceptionHandlingSettings exceptionHandlingConfiguration = null;

            if (node == null)
            {
                exceptionHandlingConfiguration = null;
            }
            else
            {
                ExceptionHandlingSettingsBuilder builder = new ExceptionHandlingSettingsBuilder(serviceProvider, node);
                exceptionHandlingConfiguration = builder.Build();
            }
            return(new ConfigurationSectionInfo(node, exceptionHandlingConfiguration, ExceptionHandlingSettings.SectionName));
        }
 public ExceptionHandlingSettingsBuilder(IServiceProvider serviceProvider, ExceptionHandlingSettingsNode exceptionHandlingSettingsNode)
 {
     this.exceptionHandlingSettingsNode = exceptionHandlingSettingsNode;
     hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
 }
示例#13
0
 public ExceptionHandlingSettingsBuilder(IServiceProvider serviceProvider, ExceptionHandlingSettingsNode exceptionHandlingSettingsNode)
 {
     this.exceptionHandlingSettingsNode = exceptionHandlingSettingsNode;
     hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
 }
 public void ExceptionHandlingSettingsNodeDefaults()
 {
     ExceptionHandlingSettingsNode settingsNode = new ExceptionHandlingSettingsNode();
     Assert.AreEqual("Exception Handling Application Block", settingsNode.Name);
 }