ExceptionPolicyEntry CreatePolicyEntry(IExceptionHandler exceptionHandler,
                                               PostHandlingAction postHandlingAction)
        {
            List <IExceptionHandler> handlerList = new List <IExceptionHandler>();

            handlerList.Add(exceptionHandler);
            ExceptionPolicyEntry policyEntry = new ExceptionPolicyEntry(postHandlingAction, handlerList);

            instrumentationProvider = new ExceptionHandlingInstrumentationProvider();
            instrumentationProvider.exceptionHandlingErrorOccurred += new EventHandler <ExceptionHandlingErrorEventArgs>(ErrorCallback);
            policyEntry.SetInstrumentationProvider(instrumentationProvider);
            return(policyEntry);
        }
        public void SetUp()
        {
            exceptionHandlerExecutedCallbackCalled = false;
            exceptionHandledCallbackCalled         = false;
            List <IExceptionHandler> handlers = new List <IExceptionHandler>();

            handlers.Add(new MockExceptionHandler(new NameValueCollection()));
            policyEntry             = new ExceptionPolicyEntry(PostHandlingAction.None, handlers);
            instrumentationProvider = new ExceptionHandlingInstrumentationProvider();
            instrumentationProvider.exceptionHandled         += new EventHandler <EventArgs>(ExceptionHandledCallback);
            instrumentationProvider.exceptionHandlerExecuted += new EventHandler <EventArgs>(ExceptionHandlerExecutedCallback);
            policyEntry.SetInstrumentationProvider(instrumentationProvider);
        }
 public ExceptionPolicyImpl(string policyName, Dictionary <Type, ExceptionPolicyEntry> policyEntries)
 {
     if (policyEntries == null)
     {
         throw new ArgumentNullException("policyEntries");
     }
     if (string.IsNullOrEmpty(policyName))
     {
         throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "policyEntries");
     }
     this.policyEntries           = policyEntries;
     this.instrumentationProvider = new ExceptionHandlingInstrumentationProvider();
     InjectPolicyNameIntoEntries(policyName, policyEntries);
     InjectInstrumentationProviderToEntries(policyEntries);
 }
        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);
        }
Exemple #5
0
 /// <summary>
 /// Attaches an <see cref="ExceptionHandlingInstrumentationProvider"/> to be used for instrumentation on this instance.
 /// </summary>
 /// <param name="provider">The <see cref="ExceptionHandlingInstrumentationProvider"/> that is attached.</param>
 public void SetInstrumentationProvider(ExceptionHandlingInstrumentationProvider provider)
 {
     this.InstrumentationProvider = provider;
 }