private ExceptionHandlingService()
        {
            ExceptionHandlingSettings section = (ExceptionHandlingSettings)ConfigurationManager
                                                .GetSection(ExceptionHandlingSettings.SectionName);

            _exceptionManager = section.BuildExceptionManager();
        }
Esempio n. 2
0
        public void CanOpenAndSaveWithCustomHandler()
        {
            System.Configuration.Configuration config   = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ExceptionHandlingSettings          settings = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];
            CustomHandlerData data = (CustomHandlerData)settings.ExceptionPolicies.Get(customPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(customHandler);

            data.Attributes.Add("Money", "0");
            config.Save(ConfigurationSaveMode.Full);

            ConfigurationManager.RefreshSection(ExceptionHandlingSettings.SectionName);
            settings = (ExceptionHandlingSettings)ConfigurationManager.GetSection(ExceptionHandlingSettings.SectionName);
            data     = (CustomHandlerData)settings.ExceptionPolicies.Get(customPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(customHandler);

            Assert.IsNotNull(data);
            Assert.AreEqual(3, data.Attributes.Count);
            Assert.AreEqual("0", data.Attributes.Get("Money"));
            data   = null;
            config = null;

            // reset
            config   = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            settings = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];
            data     = (CustomHandlerData)settings.ExceptionPolicies.Get(customPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(customHandler);
            data.Attributes.Remove("Money");
            config.Save(ConfigurationSaveMode.Full);
            ConfigurationManager.RefreshSection(ExceptionHandlingSettings.SectionName);
            settings = (ExceptionHandlingSettings)ConfigurationManager.GetSection(ExceptionHandlingSettings.SectionName);
            data     = (CustomHandlerData)settings.ExceptionPolicies.Get(customPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(customHandler);
            Assert.AreEqual(2, data.Attributes.Count);
        }
Esempio n. 3
0
        public void CanSerializeAndDeserializeSettings()
        {
            const string policyName   = "policyName";
            const string typeName     = "typeName";
            const string handlerName  = "handlerName";
            const string handler1Name = "handler1Name";

            ExceptionHandlingSettings settings   = new ExceptionHandlingSettings();
            ExceptionPolicyData       policyData = new ExceptionPolicyData(policyName);
            ExceptionTypeData         typeData   = new ExceptionTypeData(typeName, typeof(Exception), PostHandlingAction.None);

            typeData.ExceptionHandlers.Add(new WrapHandlerData(handlerName, "foo", typeof(InvalidCastException)));
            typeData.ExceptionHandlers.Add(new ReplaceHandlerData(handler1Name, "foo", typeof(InvalidCastException)));
            policyData.ExceptionTypes.Add(typeData);
            settings.ExceptionPolicies.Add(policyData);

            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

            fileMap.ExeConfigFilename = fileName;
            System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            config.Sections.Add(ExceptionHandlingSettings.SectionName, settings);
            config.Save();

            config   = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            settings = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];

            Assert.AreEqual(1, settings.ExceptionPolicies.Count);
            Assert.AreEqual(1, settings.ExceptionPolicies.Get(0).ExceptionTypes.Count);
            Assert.AreEqual(2, settings.ExceptionPolicies.Get(0).ExceptionTypes.Get(0).ExceptionHandlers.Count);
        }
Esempio n. 4
0
        public void TestCallHandlerCustomFactory()
        {
            PolicyInjectionSettings settings = new PolicyInjectionSettings();
            PolicyData policyData            = new PolicyData("policy");
            ExceptionCallHandlerData data    = new ExceptionCallHandlerData("exceptionhandler", "Swallow Exceptions");

            data.Order = 5;
            policyData.Handlers.Add(data);
            policyData.MatchingRules.Add(new CustomMatchingRuleData("matchesEverything", typeof(AlwaysMatchingRule)));
            settings.Policies.Add(policyData);

            ExceptionHandlingSettings ehabSettings      = new ExceptionHandlingSettings();
            ExceptionPolicyData       swallowExceptions = new ExceptionPolicyData("Swallow Exceptions");

            swallowExceptions.ExceptionTypes.Add(new ExceptionTypeData("Exception", typeof(Exception), PostHandlingAction.None));
            ehabSettings.ExceptionPolicies.Add(swallowExceptions);

            DictionaryConfigurationSource dictConfigurationSource = new DictionaryConfigurationSource();

            dictConfigurationSource.Add(PolicyInjectionSettings.SectionName, settings);

            IUnityContainer container = new UnityContainer().AddNewExtension <Interception>();

            settings.ConfigureContainer(container, dictConfigurationSource);
            new UnityContainerConfigurator(container).RegisterAll(dictConfigurationSource, ehabSettings);

            InjectionFriendlyRuleDrivenPolicy policy = container.Resolve <InjectionFriendlyRuleDrivenPolicy>("policy");

            ICallHandler handler
                = (policy.GetHandlersFor(new MethodImplementationInfo(null, (MethodInfo)MethodBase.GetCurrentMethod()), container)).ElementAt(0);

            Assert.IsNotNull(handler);
            Assert.AreEqual(handler.Order, data.Order);
        }
Esempio n. 5
0
        public void CanOpenAndSaveWithWrapHandler()
        {
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ExceptionHandlingSettings settings = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];
            WrapHandlerData           data     = (WrapHandlerData)settings.ExceptionPolicies.Get(wrapPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(wrapHandler);
            string oldName = data.Name;

            data.Name = newWrapHandler;
            config.Save(ConfigurationSaveMode.Full);

            ConfigurationManager.RefreshSection(ExceptionHandlingSettings.SectionName);
            settings = (ExceptionHandlingSettings)ConfigurationManager.GetSection(ExceptionHandlingSettings.SectionName);
            data     = (WrapHandlerData)settings.ExceptionPolicies.Get(wrapPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(newWrapHandler);


            Assert.IsNotNull(data);
            Assert.AreEqual(data.Name, newWrapHandler);

            // reset
            config    = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            settings  = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];
            data      = (WrapHandlerData)settings.ExceptionPolicies.Get(wrapPolicy).ExceptionTypes.Get(exceptionType).ExceptionHandlers.Get(newWrapHandler);
            data.Name = oldName;
            config.Save(ConfigurationSaveMode.Full);
            ConfigurationManager.RefreshSection(ExceptionHandlingSettings.SectionName);
        }
Esempio n. 6
0
        public void CanReadAndWriteLoggingHandler()
        {
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

            fileMap.ExeConfigFilename = "test.exe.config";
            SysConfig.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            config.Sections.Remove(ExceptionHandlingSettings.SectionName);
            config.Sections.Add(ExceptionHandlingSettings.SectionName, CreateSettings());
            config.Save(ConfigurationSaveMode.Full);

            config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            ExceptionHandlingSettings         settings = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];
            FaultContractExceptionHandlerData data     = (FaultContractExceptionHandlerData)settings.ExceptionPolicies.Get("test").ExceptionTypes.Get("test").ExceptionHandlers.Get("test");

            config.Sections.Remove(ExceptionHandlingSettings.SectionName);
            config.Save(ConfigurationSaveMode.Full);


            Assert.AreEqual("test", data.Name);
            Assert.AreEqual(typeof(object).AssemblyQualifiedName, data.FaultContractType);
            Assert.AreEqual("my exception message", data.ExceptionMessage);
            Assert.AreEqual(2, data.PropertyMappings.Count);
            Assert.AreEqual("source1", data.PropertyMappings.Get("property1").Source);
            Assert.AreEqual("source2", data.PropertyMappings.Get("property2").Source);
        }
Esempio n. 7
0
        public void CanReadAndWriteLoggingHandler()
        {
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

            fileMap.ExeConfigFilename = "test.exe.config";
            System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            config.Sections.Remove(ExceptionHandlingSettings.SectionName);
            config.Sections.Add(ExceptionHandlingSettings.SectionName, CreateSettings());
            config.Save(ConfigurationSaveMode.Full);

            config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            ExceptionHandlingSettings   settings = (ExceptionHandlingSettings)config.Sections[ExceptionHandlingSettings.SectionName];
            LoggingExceptionHandlerData data     = (LoggingExceptionHandlerData)settings.ExceptionPolicies.Get("test").ExceptionTypes.Get("test").ExceptionHandlers.Get("test");

            config.Sections.Remove(ExceptionHandlingSettings.SectionName);
            config.Save(ConfigurationSaveMode.Full);

            Assert.AreEqual("test", data.Name);
            Assert.AreEqual("cat1", data.LogCategory);
            Assert.AreEqual(1, data.EventId);
            Assert.AreEqual(TraceEventType.Error, data.Severity);
            Assert.AreEqual("title", data.Title);
            Assert.AreEqual(typeof(XmlExceptionFormatter), data.FormatterType);
            Assert.AreEqual(4, data.Priority);
        }
Esempio n. 8
0
        public void GetPolicyByNameFailTest()
        {
            ExceptionHandlingSettings settings = (ExceptionHandlingSettings)
                                                 new SystemConfigurationSource(false).GetSection(ExceptionHandlingSettings.SectionName);

            settings.ExceptionPolicies.Get(badString);
        }
Esempio n. 9
0
        [Ignore]    // TODO the configurator will not work as currently designed
        public void CanCreateExceptionHandlerFromConfiguration()
        {
            PolicyInjectionSettings settings = new PolicyInjectionSettings();
            PolicyData policyData            = new PolicyData("policy");

            policyData.Handlers.Add(new ExceptionCallHandlerData("exceptionhandler", "Swallow Exceptions"));
            policyData.MatchingRules.Add(new CustomMatchingRuleData("matchesEverything", typeof(AlwaysMatchingRule)));
            settings.Policies.Add(policyData);

            ExceptionHandlingSettings ehabSettings      = new ExceptionHandlingSettings();
            ExceptionPolicyData       swallowExceptions = new ExceptionPolicyData("Swallow Exceptions");

            swallowExceptions.ExceptionTypes.Add(new ExceptionTypeData("Exception", typeof(Exception), PostHandlingAction.None));
            ehabSettings.ExceptionPolicies.Add(swallowExceptions);
            DictionaryConfigurationSource dictConfigurationSource = new DictionaryConfigurationSource();

            dictConfigurationSource.Add(PolicyInjectionSettings.SectionName, settings);
            dictConfigurationSource.Add(ExceptionHandlingSettings.SectionName, ehabSettings);

            using (PolicyInjector injector = new PolicyInjector(dictConfigurationSource))
            {
                TargetType target = injector.Create <TargetType>();
                target.WillThrowException();
            }
        }
        public void RuntimeTest()
        {
            ExceptionPolicyData policyData = new ExceptionPolicyData();

            policyData.Name = "Default Policy";

            ExceptionTypeData typeData = new ExceptionTypeData();

            typeData.Name = "ApplicationException";

            CustomHandlerData handlerData = new CustomHandlerData();

            handlerData.Name = "MockExceptionHandler";

            ExceptionHandlingSettings settings = new ExceptionHandlingSettings();

            settings.ExceptionPolicies.Add(policyData);
            //settings.ExceptionPolicies[policyData.Name].ExceptionTypes = new ExceptionTypeDataCollection();
            settings.ExceptionPolicies[policyData.Name].ExceptionTypes.Add(typeData);
            //settings.ExceptionPolicies[policyData.Name].ExceptionTypes[typeData.Name].ExceptionHandlers = new ExceptionHandlerDataCollection();
            settings.ExceptionPolicies[policyData.Name].ExceptionTypes[typeData.Name].ExceptionHandlers.Add(handlerData);

            ExceptionHandlingSettingsNode settingsNode = new ExceptionHandlingSettingsNode(settings);

            HierarchyService.SelectedHierarchy.RootNode.Nodes.Add(settingsNode);
            Assert.AreEqual(policyData.Name, settingsNode.Nodes[0].Name);
            Assert.AreEqual(typeData.Name, settingsNode.Nodes[0].Nodes[0].Name);
            Assert.AreEqual(handlerData.Name, settingsNode.Nodes[0].Nodes[0].Nodes[0].Name);
        }
        public void CanDeserializeSerializedConfiguration()
        {
            ExceptionHandlingSettings settings   = new ExceptionHandlingSettings();
            ExceptionTypeData         typeData11 = new ExceptionTypeData(typeName11, typeof(ArgumentNullException), PostHandlingAction.None);

            typeData11.ExceptionHandlers.Add(new LoggingExceptionHandlerData(handlerName111, handlerCategory111, 100, TraceEventType.Information, handlerMessage111, typeof(ExceptionFormatter), 101));
            ExceptionPolicyData policyData1 = new ExceptionPolicyData(policyName1);

            policyData1.ExceptionTypes.Add(typeData11);
            settings.ExceptionPolicies.Add(policyData1);
            IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>();

            sections[ExceptionHandlingSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);
            ExceptionHandlingSettings roSettigs = (ExceptionHandlingSettings)configurationSource.GetSection(ExceptionHandlingSettings.SectionName);

            Assert.IsNotNull(roSettigs);
            Assert.AreEqual(1, roSettigs.ExceptionPolicies.Count);
            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1));
            Assert.AreEqual(1, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Count);
            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11));
            Assert.AreSame(typeof(ArgumentNullException), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).Type);
            Assert.AreEqual(1, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Count);
            Assert.AreSame(typeof(LoggingExceptionHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111).GetType());
            Assert.AreEqual(100, ((LoggingExceptionHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).EventId);
            Assert.AreEqual(typeof(ExceptionFormatter), ((LoggingExceptionHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).FormatterType);
            Assert.AreEqual(handlerCategory111, ((LoggingExceptionHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).LogCategory);
            Assert.AreEqual(101, ((LoggingExceptionHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).Priority);
            Assert.AreEqual(TraceEventType.Information, ((LoggingExceptionHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).Severity);
            Assert.AreEqual(handlerMessage111, ((LoggingExceptionHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).Title);
        }
        protected override void Arrange()
        {
            base.Arrange();

            validator = new LogFormatterValidator();

            errors = new List <ValidationResult>();

            IConfigurationSource       source       = new DictionaryConfigurationSource();
            ConfigurationSourceBuilder sourceBuiler = new ConfigurationSourceBuilder();

            sourceBuiler.ConfigureExceptionHandling()
            .GivenPolicyWithName("policy")
            .ForExceptionType <Exception>()
            .LogToCategory("category")
            .UsingExceptionFormatter <BadImageFormatException>();

            sourceBuiler.UpdateConfigurationWithReplace(source);

            ExceptionHandlingSettings EhabSettings = (ExceptionHandlingSettings)source.GetSection(ExceptionHandlingSettings.SectionName);

            var sectionModel = SectionViewModel.CreateSection(Container, "Ehab Section", EhabSettings);

            properties = sectionModel.GetDescendentsOfType <LoggingExceptionHandlerData>().First().Properties;
        }
        /// <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);
                }
            }
        }
Esempio n. 14
0
        public void BuildsWcfExceptionShildingWithFluentConfiguration()
        {
            DictionaryConfigurationSource emptyConfigSource = new DictionaryConfigurationSource();

            ConfigurationSourceBuilder builder = new ConfigurationSourceBuilder();

            builder.ConfigureExceptionHandling()
            .GivenPolicyWithName("policy")
            .ForExceptionType(typeof(NotFiniteNumberException))
            .ShieldExceptionForWcf(typeof(MockFaultContract), "fault message")
            .MapProperty("Message", "{Message}")
            .MapProperty("Data", "{Data}")
            .MapProperty("SomeNumber", "{OffendingNumber}")
            .ThenThrowNewException();

            builder.UpdateConfigurationWithReplace(emptyConfigSource);

            ExceptionHandlingSettings settings = emptyConfigSource.GetSection(ExceptionHandlingSettings.SectionName) as ExceptionHandlingSettings;

            Assert.IsNotNull(settings);
            Assert.AreEqual(1, settings.ExceptionPolicies.Count);
            var policy = settings.ExceptionPolicies.Get("policy");

            Assert.IsNotNull(policy);
            Assert.AreEqual(1, policy.ExceptionTypes.Count);
            var configuredException = policy.ExceptionTypes.Get(0);

            Assert.AreEqual(typeof(NotFiniteNumberException), configuredException.Type);
            Assert.AreEqual(PostHandlingAction.ThrowNewException, configuredException.PostHandlingAction);
            Assert.AreEqual(1, configuredException.ExceptionHandlers.Count);

            var handler = configuredException.ExceptionHandlers.Get(0) as FaultContractExceptionHandlerData;

            Assert.IsNotNull(handler);
            Assert.AreEqual(typeof(MockFaultContract).AssemblyQualifiedName, handler.FaultContractType);
            Assert.AreEqual("fault message", handler.ExceptionMessage);
            Assert.AreEqual(3, handler.PropertyMappings.Count);
            Assert.IsNotNull(handler.PropertyMappings.SingleOrDefault(p => p.Name == "Message" && p.Source == "{Message}"));
            Assert.IsNotNull(handler.PropertyMappings.SingleOrDefault(p => p.Name == "Data" && p.Source == "{Data}"));
            Assert.IsNotNull(handler.PropertyMappings.SingleOrDefault(p => p.Name == "SomeNumber" && p.Source == "{OffendingNumber}"));

            var exceptionManager = settings.BuildExceptionManager();
            NotFiniteNumberException originalException = new NotFiniteNumberException("MyException", 555);

            originalException.Data.Add("someKey", "someValue");
            try
            {
                exceptionManager.HandleException(originalException, "policy");
                Assert.Fail("Should have thrown");
            }
            catch (FaultContractWrapperException ex)
            {
                MockFaultContract fault = (MockFaultContract)ex.FaultContract;
                Assert.AreEqual(originalException.Message, fault.Message);
                Assert.AreEqual(originalException.Data.Count, fault.Data.Count);
                Assert.AreEqual(originalException.Data["someKey"], fault.Data["someKey"]);
                Assert.AreEqual(originalException.OffendingNumber, fault.SomeNumber);
            }
        }
Esempio n. 15
0
        public void GetExceptionHandlingSettingsFromConfiguration()
        {
            ExceptionHandlingConfigurationView view     = new ExceptionHandlingConfigurationView(new SystemConfigurationSource());
            ExceptionHandlingSettings          settings = view.ExceptionHandlingSettings;

            Assert.IsNotNull(settings);
            Assert.AreEqual(3, settings.ExceptionPolicies.Count);
        }
Esempio n. 16
0
 public void SetUp()
 {
     container           = new UnityContainer();
     settings            = new ExceptionHandlingSettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add(ExceptionHandlingSettings.SectionName, settings);
     container.AddExtension(new EnterpriseLibraryCoreExtension(configurationSource));
 }
Esempio n. 17
0
        public void GetPolicyByNameFailTest()
        {
            TestConfigurationContext  context    = new TestConfigurationContext();
            ExceptionHandlingSettings settings   = (ExceptionHandlingSettings)context.GetConfiguration(ExceptionHandlingSettings.SectionName);
            ExceptionPolicyData       testPolicy = settings.ExceptionPolicies[BadString];

            Assert.IsNull(testPolicy);
        }
        /// <summary>
        /// <para>Gets the collection of <see cref="ExceptionHandlerData"/> objects for a policy based on an excetion type.</para>
        /// </summary>
        /// <param name="policyName">
        /// <para>The name of the <see cref="ExceptionPolicy"/> for the data.</para>
        /// </param>
        /// <param name="exceptionTypeName">
        /// <para>The <see cref="Exception"/> type that will be handled.</para>
        /// </param>
        /// <returns><para>An <see cref="ExceptionHandlerDataCollection"/> object.</para></returns>
        public virtual ExceptionHandlerDataCollection GetExceptionHandlerDataCollection(string policyName, string exceptionTypeName)
        {
            ValidatePolicyName(policyName);
            ValidateExceptionTypeName(exceptionTypeName);

            ExceptionHandlingSettings settings = GetExceptionHandlingSettings();

            return(GetExceptionHandlerDataCollection(settings, policyName, exceptionTypeName));
        }
Esempio n. 19
0
        /// <summary>
        /// Initialises a new instance of the <see cref="EnterpriseExceptionManager"/> class.
        /// </summary>
        public EnterpriseExceptionManager()
        {
            ExceptionHandlingSettings section = ConfigurationManager.GetSection(ExceptionHandlingSettings.SectionName) as ExceptionHandlingSettings;

            if (section != null)
            {
                _exceptionManager = section.BuildExceptionManager();
            }
        }
 public void SetUp()
 {
     settings            = new ExceptionHandlingSettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add(ExceptionHandlingSettings.SectionName, settings);
     configurationSource.Add(
         InstrumentationConfigurationSection.SectionName,
         new InstrumentationConfigurationSection(false, false));
 }
Esempio n. 21
0
        public void CanDeserializeSerializedConfiguration()
        {
            ExceptionHandlingSettings settings = new ExceptionHandlingSettings();

            ExceptionTypeData typeData11 = new ExceptionTypeData(typeName11, typeof(ArgumentNullException), PostHandlingAction.None);

            typeData11.ExceptionHandlers.Add(new ReplaceHandlerData(handlerName111, handlerMessage111, typeof(ApplicationException)));
            typeData11.ExceptionHandlers.Add(new WrapHandlerData(handlerName112, handlerMessage112, typeof(ApplicationException)));

            ExceptionTypeData typeData12 = new ExceptionTypeData(typeName12, typeof(ArgumentException), PostHandlingAction.NotifyRethrow);

            typeData12.ExceptionHandlers.Add(new CustomHandlerData(handlerName121, typeof(MockExceptionHandler)));

            ExceptionPolicyData policyData1 = new ExceptionPolicyData(policyName1);

            policyData1.ExceptionTypes.Add(typeData11);
            policyData1.ExceptionTypes.Add(typeData12);

            ExceptionPolicyData policyData2 = new ExceptionPolicyData(policyName2);

            settings.ExceptionPolicies.Add(policyData1);
            settings.ExceptionPolicies.Add(policyData2);

            IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>();

            sections[ExceptionHandlingSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            ExceptionHandlingSettings roSettigs = (ExceptionHandlingSettings)configurationSource.GetSection(ExceptionHandlingSettings.SectionName);

            Assert.IsNotNull(roSettigs);
            Assert.AreEqual(2, roSettigs.ExceptionPolicies.Count);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1));
            Assert.AreEqual(2, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Count);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11));
            Assert.AreSame(typeof(ArgumentNullException), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).Type);
            Assert.AreEqual(2, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Count);
            Assert.AreSame(typeof(ReplaceHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111).GetType());
            Assert.AreEqual(handlerMessage111, ((ReplaceHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).ExceptionMessage);
            Assert.AreEqual(typeof(ApplicationException), ((ReplaceHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).ReplaceExceptionType);
            Assert.AreSame(typeof(WrapHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName112).GetType());
            Assert.AreEqual(handlerMessage112, ((WrapHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName112)).ExceptionMessage);
            Assert.AreEqual(typeof(ApplicationException), ((WrapHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName112)).WrapExceptionType);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12));
            Assert.AreSame(typeof(ArgumentException), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).Type);
            Assert.AreEqual(1, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).ExceptionHandlers.Count);
            Assert.AreSame(typeof(CustomHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).ExceptionHandlers.Get(handlerName121).GetType());
            Assert.AreEqual(typeof(MockExceptionHandler), ((CustomHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).ExceptionHandlers.Get(handlerName121)).Type);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName2));
            Assert.AreEqual(0, roSettigs.ExceptionPolicies.Get(policyName2).ExceptionTypes.Count);
        }
        /// <summary>
        /// <para>Gets the <see cref="ExceptionHandlerData"/> from configuration for the policy and specific exception type.</para>
        /// </summary>
        /// <param name="policyName">
        /// <para>The name of the <see cref="ExceptionPolicy"/> for the data.</para>
        /// </param>
        /// <param name="exceptionTypeName">
        /// <para>The <see cref="Exception"/> type that will be handled.</para>
        /// </param>
        /// <param name="handlerName"><para>The name of the handler to retrieve from configuration.</para></param>
        /// <returns>
        /// <para>An <see cref="ExceptionHandlerData"/> object.</para>
        /// </returns>
        public virtual ExceptionHandlerData GetExceptionHandlerData(string policyName, string exceptionTypeName, string handlerName)
        {
            ValidatePolicyName(policyName);
            ValidateExceptionTypeName(exceptionTypeName);
            ValidateHandlerName(handlerName);

            ExceptionHandlingSettings settings = (ExceptionHandlingSettings)ConfigurationContext.GetConfiguration(ExceptionHandlingSettings.SectionName);

            return(GetExceptionHandlerData(settings, policyName, exceptionTypeName, handlerName));
        }
        public void Then_ConfigurationSourceContainsBothPolicies()
        {
            ExceptionHandlingSettings settings = (ExceptionHandlingSettings)GetConfigurationSource().GetSection(ExceptionHandlingSettings.SectionName);

            var anotherPolicy = settings.ExceptionPolicies.Get("anotherPolicy");

            Assert.AreEqual(2, anotherPolicy.ExceptionTypes.Count());
            Assert.IsTrue(anotherPolicy.ExceptionTypes.Any(x => x.Type == typeof(TimeZoneNotFoundException)));;
            Assert.IsTrue(anotherPolicy.ExceptionTypes.Any(x => x.Type == typeof(ArithmeticException)));
        }
            private void EnsureExceptionHandlingSection()
            {
                exceptionSettingsSection = GetSectionOfType <ExceptionHandlingSettings>();

                if (exceptionSettingsSection == null)
                {
                    var section = new ExceptionHandlingSettings();
                    exceptionSettingsSection = SourceModel.AddSection(ExceptionHandlingSettings.SectionName, section);
                }
            }
Esempio n. 25
0
 public ExceptionHandlingSettings Build()
 {
     exceptionHandlingSettings = new ExceptionHandlingSettings();
     if (!this.exceptionHandlingSettingsNode.RequirePermission)                  // don't set if false
     {
         exceptionHandlingSettings.SectionInformation.RequirePermission = this.exceptionHandlingSettingsNode.RequirePermission;
     }
     BuildPolicies();
     return(exceptionHandlingSettings);
 }
        /// <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;
            }
        }
Esempio n. 27
0
 public void SetUp()
 {
     provider =
         new ExceptionHandlingSettingsManageabilityProvider(
             new Dictionary <Type, ConfigurationElementManageabilityProvider>(0));
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     section             = new ExceptionHandlingSettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add(ExceptionHandlingSettings.SectionName, section);
 }
 public void SetUp()
 {
     provider =
         new ExceptionHandlingSettingsManageabilityProvider(
             new Dictionary<Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     section = new ExceptionHandlingSettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add(ExceptionHandlingSettings.SectionName, section);
 }
        private static ExceptionTypeData GetExceptionTypeData(ExceptionHandlingSettings settings, string policyName, string exceptionTypeName)
        {
            ExceptionTypeDataCollection exceptionTypeDataCollection = GetExceptionTypeDataCollection(settings, policyName);
            ExceptionTypeData           exceptionTypeData           = exceptionTypeDataCollection[exceptionTypeName];

            if (exceptionTypeData == null)
            {
                throw new ConfigurationException(SR.ExceptionExceptionTypeNotFound(exceptionTypeName, policyName));
            }

            return(exceptionTypeData);
        }
        private static ExceptionPolicyData GetExceptionPolicyData(ExceptionHandlingSettings settings, string policyName)
        {
            ExceptionPolicyDataCollection exceptionPolicyDataCollection = settings.ExceptionPolicies;
            ExceptionPolicyData           exceptionPolicyData           = exceptionPolicyDataCollection[policyName];

            if (exceptionPolicyData == null)
            {
                throw new ConfigurationException(SR.ExceptionSimpleProviderNotFound(policyName));
            }

            return(exceptionPolicyData);
        }
        private ExceptionHandlerData GetExceptionHandlerData(ExceptionHandlingSettings settings, string policyName, string exceptionTypeName, string handlerName)
        {
            ExceptionHandlerDataCollection exceptionHandlerDataCollection = GetExceptionHandlerDataCollection(settings, policyName, exceptionTypeName);
            ExceptionHandlerData           data = exceptionHandlerDataCollection[handlerName];

            if (data == null)
            {
                throw new ConfigurationException(SR.ExceptionExceptionHanlderNotFoun(handlerName, exceptionTypeName, policyName));
            }

            return(data);
        }
        public void CanDeserializeSerializedConfiguration()
        {
            ExceptionHandlingSettings settings = new ExceptionHandlingSettings();

            ExceptionTypeData typeData11 = new ExceptionTypeData(typeName11, typeof(ArgumentNullException), PostHandlingAction.None);
            typeData11.ExceptionHandlers.Add(new ReplaceHandlerData(handlerName111, handlerMessage111, typeof(ApplicationException)));
            typeData11.ExceptionHandlers.Add(new WrapHandlerData(handlerName112, handlerMessage112, typeof(ApplicationException)));

            ExceptionTypeData typeData12 = new ExceptionTypeData(typeName12, typeof(ArgumentException), PostHandlingAction.NotifyRethrow);
            typeData12.ExceptionHandlers.Add(new CustomHandlerData(handlerName121, typeof(MockExceptionHandler)));

            ExceptionPolicyData policyData1 = new ExceptionPolicyData(policyName1);
            policyData1.ExceptionTypes.Add(typeData11);
            policyData1.ExceptionTypes.Add(typeData12);

            ExceptionPolicyData policyData2 = new ExceptionPolicyData(policyName2);

            settings.ExceptionPolicies.Add(policyData1);
            settings.ExceptionPolicies.Add(policyData2);

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>();
            sections[ExceptionHandlingSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            ExceptionHandlingSettings roSettigs = (ExceptionHandlingSettings)configurationSource.GetSection(ExceptionHandlingSettings.SectionName);

            Assert.IsNotNull(roSettigs);
            Assert.AreEqual(2, roSettigs.ExceptionPolicies.Count);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1));
            Assert.AreEqual(2, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Count);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11));
            Assert.AreSame(typeof(ArgumentNullException), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).Type);
            Assert.AreEqual(2, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Count);
            Assert.AreSame(typeof(ReplaceHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111).GetType());
            Assert.AreEqual(handlerMessage111, ((ReplaceHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).ExceptionMessage);
            Assert.AreEqual(typeof(ApplicationException), ((ReplaceHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName111)).ReplaceExceptionType);
            Assert.AreSame(typeof(WrapHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName112).GetType());
            Assert.AreEqual(handlerMessage112, ((WrapHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName112)).ExceptionMessage);
            Assert.AreEqual(typeof(ApplicationException), ((WrapHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName11).ExceptionHandlers.Get(handlerName112)).WrapExceptionType);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12));
            Assert.AreSame(typeof(ArgumentException), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).Type);
            Assert.AreEqual(1, roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).ExceptionHandlers.Count);
            Assert.AreSame(typeof(CustomHandlerData), roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).ExceptionHandlers.Get(handlerName121).GetType());
            Assert.AreEqual(typeof(MockExceptionHandler), ((CustomHandlerData)roSettigs.ExceptionPolicies.Get(policyName1).ExceptionTypes.Get(typeName12).ExceptionHandlers.Get(handlerName121)).Type);

            Assert.IsNotNull(roSettigs.ExceptionPolicies.Get(policyName2));
            Assert.AreEqual(0, roSettigs.ExceptionPolicies.Get(policyName2).ExceptionTypes.Count);
        }
        public void Setup()
        {
            settings = new ExceptionHandlingSettings();
            var exceptionPolicyData = new ExceptionPolicyData("aPolicy");
            var exceptionType = new ExceptionTypeData("ExceptionType", typeof(ArgumentNullException),
                                                      PostHandlingAction.ThrowNewException);
            exceptionType.ExceptionHandlers.Add(
                new WrapHandlerData("aWrapHandler", "exception", typeof(Exception).AssemblyQualifiedName)
                );

            exceptionPolicyData.ExceptionTypes.Add(exceptionType);
            settings.ExceptionPolicies.Add(exceptionPolicyData);
        }
        public void RuntimeTest()
        {
            ExceptionPolicyData policyData = new ExceptionPolicyData();
            policyData.Name = "Default Policy";

            ExceptionTypeData typeData = new ExceptionTypeData();
            typeData.Name = "ApplicationException";

            CustomHandlerData handlerData = new CustomHandlerData();
            handlerData.Name = "MockExceptionHandler";

            ExceptionHandlingSettings settings = new ExceptionHandlingSettings();
            settings.ExceptionPolicies.Add(policyData);
            //settings.ExceptionPolicies[policyData.Name].ExceptionTypes = new ExceptionTypeDataCollection();
            settings.ExceptionPolicies[policyData.Name].ExceptionTypes.Add(typeData);
            //settings.ExceptionPolicies[policyData.Name].ExceptionTypes[typeData.Name].ExceptionHandlers = new ExceptionHandlerDataCollection();
            settings.ExceptionPolicies[policyData.Name].ExceptionTypes[typeData.Name].ExceptionHandlers.Add(handlerData);

            ExceptionHandlingSettingsNode settingsNode = new ExceptionHandlingSettingsNode(settings);
            HierarchyService.SelectedHierarchy.RootNode.Nodes.Add(settingsNode);
            Assert.AreEqual(policyData.Name, settingsNode.Nodes[0].Name);
            Assert.AreEqual(typeData.Name, settingsNode.Nodes[0].Nodes[0].Name);
            Assert.AreEqual(handlerData.Name, settingsNode.Nodes[0].Nodes[0].Nodes[0].Name);
        }
		public ExceptionHandlingSettingsNodeBuilder(IServiceProvider serviceProvider, ExceptionHandlingSettings settings)
			: base(serviceProvider)
		{
			this.settings = settings;			
		}
        public void Setup()
        {
            settings = new ExceptionHandlingSettings();

            var exceptionPolicyData = new ExceptionPolicyData("aPolicy");
            var exceptionType = new ExceptionTypeData("ExceptionType", typeof(ArgumentNullException),
                                                      PostHandlingAction.None);
            exceptionPolicyData.ExceptionTypes.Add(exceptionType);
            settings.ExceptionPolicies.Add(exceptionPolicyData);

            var exceptionPolicyData2 = new ExceptionPolicyData("anotherPolicy");
            var exceptionType2 = new ExceptionTypeData("ExceptionType", typeof(ArgumentNullException),
                                                       PostHandlingAction.None);
            exceptionPolicyData2.ExceptionTypes.Add(exceptionType2);
            settings.ExceptionPolicies.Add(exceptionPolicyData2);
        }
        public void Setup()
        {
            settings = new ExceptionHandlingSettings();

            var exceptionPolicyData1 = new ExceptionPolicyData("policy1");
            settings.ExceptionPolicies.Add(exceptionPolicyData1);
            var exceptionType11 = new ExceptionTypeData("ArgumentNullException", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData1.ExceptionTypes.Add(exceptionType11);
            exceptionType11.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            var exceptionType12 = new ExceptionTypeData("ArgumentException", typeof(ArgumentException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData1.ExceptionTypes.Add(exceptionType12);
            exceptionType12.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            exceptionType12.ExceptionHandlers.Add(
                new WrapHandlerData("handler2", "message", typeof(Exception).AssemblyQualifiedName));


            var exceptionPolicyData2 = new ExceptionPolicyData("policy2");
            settings.ExceptionPolicies.Add(exceptionPolicyData2);
            var exceptionType21 = new ExceptionTypeData("ArgumentNullException", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData2.ExceptionTypes.Add(exceptionType21);
            exceptionType21.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            exceptionType21.ExceptionHandlers.Add(
                new WrapHandlerData("handler3", "message", typeof(Exception).AssemblyQualifiedName));

            this.manager = (ExceptionManager)this.settings.BuildExceptionManager();
        }
 /// <summary>
 /// Creates the root node for Exception Handling and builds the designtime tree
 /// based on the supplied runtime settings.
 /// </summary>
 /// <param name="exceptionHandlingSettings">The Exception Handling runtime settings.</param>
 public ExceptionHandlingSettingsNode(ExceptionHandlingSettings exceptionHandlingSettings)
     : base()
 {
     this.exceptionHandlingSettings = exceptionHandlingSettings;
 }
 public void Setup()
 {
     settings = new ExceptionHandlingSettings();
 }
 public ExceptionHandlingSettings Build()
 {
     exceptionHandlingSettings = new ExceptionHandlingSettings();
     BuildPolicies();
     return exceptionHandlingSettings;
 }
        public void Setup()
        {
            settings = new ExceptionHandlingSettings();

            var exceptionPolicyData1 = new ExceptionPolicyData("policy1");
            settings.ExceptionPolicies.Add(exceptionPolicyData1);
            var exceptionType11 = new ExceptionTypeData("ExceptionType1", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData1.ExceptionTypes.Add(exceptionType11);
            exceptionType11.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            var exceptionType12 = new ExceptionTypeData("ExceptionType2", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData1.ExceptionTypes.Add(exceptionType12);
            exceptionType12.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            exceptionType12.ExceptionHandlers.Add(
                new WrapHandlerData("handler2", "message", typeof(Exception).AssemblyQualifiedName));


            var exceptionPolicyData2 = new ExceptionPolicyData("policy2");
            settings.ExceptionPolicies.Add(exceptionPolicyData2);
            var exceptionType21 = new ExceptionTypeData("ExceptionType1", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData2.ExceptionTypes.Add(exceptionType21);
            exceptionType21.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            exceptionType21.ExceptionHandlers.Add(
                new WrapHandlerData("handler3", "message", typeof(Exception).AssemblyQualifiedName));

            registrations = settings.GetRegistrations(null);
        }