/// <summary>
        /// Initializes a new instance of the <see cref="ExceptionPolicyEntry"/> class.
        /// </summary>
        /// <param name="exceptionType">Type of exception this policy refers to.</param>
        /// <param name="postHandlingAction">What to do after the exception is handled.</param>
        /// <param name="handlers">Handlers to execute on the exception.</param>
        /// <param name="instrumentationProvider">Instrumentation provider</param>
        public ExceptionPolicyEntry(
            Type exceptionType, 
            PostHandlingAction postHandlingAction, 
            IEnumerable<IExceptionHandler> handlers, 
            IExceptionHandlingInstrumentationProvider instrumentationProvider)
        {
            if (exceptionType == null) throw new ArgumentNullException("exceptionType");
            if (handlers == null) throw new ArgumentNullException("handlers");
            if(instrumentationProvider == null) throw new ArgumentNullException("instrumentationProvider");

            ExceptionType = exceptionType;
            this.postHandlingAction = postHandlingAction;
            this.handlers = handlers;
            this.instrumentationProvider = instrumentationProvider;
        }
        public void SetUp()
        {
            var handlers = new IExceptionHandler[] { new MockThrowingExceptionHandler() };

            var instrumentationProvider = new ExceptionHandlingInstrumentationProvider(policyName, true, true,
                                                                                       "ApplicationInstanceName");
            var policyEntry   = new ExceptionPolicyEntry(typeof(ArgumentException), PostHandlingAction.None, handlers, instrumentationProvider);
            var policyEntries = new Dictionary <Type, ExceptionPolicyEntry>
            {
                { typeof(ArgumentException), policyEntry }
            };

            exceptionPolicy = new ExceptionPolicyImpl(policyName, policyEntries);

            nameFormatter                  = new FixedPrefixNameFormatter("Prefix - ");
            provider                       = new ExceptionHandlingInstrumentationProvider(instanceName, true, true, nameFormatter);
            formattedInstanceName          = nameFormatter.CreateName(instanceName);
            totalExceptionHandlersExecuted = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalExceptionHandlersExecuted, formattedInstanceName);
            totalExceptionsHandled         = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalExceptionsHandled, formattedInstanceName);
        }
        public void SetUp()
        {
            var handlers = new IExceptionHandler[] { new MockThrowingExceptionHandler() };

            var instrumentationProvider = new ExceptionHandlingInstrumentationProvider(policyName, true, true,
                                                                                          "ApplicationInstanceName");
            var policyEntry = new ExceptionPolicyEntry(typeof(ArgumentException), PostHandlingAction.None, handlers, instrumentationProvider);
            var policyEntries = new Dictionary<Type, ExceptionPolicyEntry>
            {
                {typeof (ArgumentException), policyEntry}
            };

            exceptionPolicy = new ExceptionPolicyImpl(policyName, policyEntries);

            nameFormatter = new FixedPrefixNameFormatter("Prefix - ");
            provider = new ExceptionHandlingInstrumentationProvider(instanceName, true, true, nameFormatter);
            formattedInstanceName = nameFormatter.CreateName(instanceName);
            totalExceptionHandlersExecuted = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalExceptionHandlersExecuted, formattedInstanceName);
            totalExceptionsHandled = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalExceptionsHandled, formattedInstanceName);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionPolicyEntry"/> class.
        /// </summary>
        /// <param name="exceptionType">Type of exception this policy refers to.</param>
        /// <param name="postHandlingAction">What to do after the exception is handled.</param>
        /// <param name="handlers">Handlers to execute on the exception.</param>
        /// <param name="instrumentationProvider">Instrumentation provider</param>
        public ExceptionPolicyEntry(
            Type exceptionType,
            PostHandlingAction postHandlingAction,
            IEnumerable <IExceptionHandler> handlers,
            IExceptionHandlingInstrumentationProvider instrumentationProvider)
        {
            if (exceptionType == null)
            {
                throw new ArgumentNullException("exceptionType");
            }
            if (handlers == null)
            {
                throw new ArgumentNullException("handlers");
            }
            if (instrumentationProvider == null)
            {
                throw new ArgumentNullException("instrumentationProvider");
            }

            ExceptionType                = exceptionType;
            this.postHandlingAction      = postHandlingAction;
            this.handlers                = handlers;
            this.instrumentationProvider = instrumentationProvider;
        }