Esempio n. 1
0
        /// <summary>
        /// Initializes the module and prepares it to handle requests.
        /// </summary>

        public virtual void Init(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            ErrorFilterConfiguration config = (ErrorFilterConfiguration)Configuration.GetSubsection("errorFilter");

            if (config == null)
            {
                return;
            }

            _assertion = config.Assertion;

            foreach (IHttpModule module in HttpModuleRegistry.GetModules(application))
            {
                IExceptionFiltering filtering = module as IExceptionFiltering;

                if (filtering != null)
                {
                    filtering.Filtering += new ExceptionFilterEventHandler(OnErrorModuleFiltering);
                }
            }
        }
Esempio n. 2
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
                throw new ArgumentNullException("section");
            
            //
            // Either inherit the incoming parent configuration (for example
            // from the machine configuration file) or start with a fresh new
            // one.
            //

            ErrorFilterConfiguration config;

            if (parent != null)
            {
                var parentConfig = (ErrorFilterConfiguration) parent;
                config = parentConfig.CloneObject();
            }    
            else
            {
                config = new ErrorFilterConfiguration();
            }

            //
            // Take the first child of <test> and turn it into the
            // assertion.
            //

            var assertionNode = (XmlElement) section.SelectSingleNode("test/*");

            if (assertionNode != null)
                config.SetAssertion(AssertionFactory.Create(assertionNode));

            return config;
        }
Esempio n. 3
0
        public static void Start()
        {
            HttpApplication.RegisterModule(typeof(ErrorLogModule));//透過程式記錄
            HttpApplication.RegisterModule(typeof(MyErrorMailModule));
            //   HttpApplication.RegisterModule(typeof(MyErrorFilterModule));

            Elmah.ServiceCenter.Current = ElmahServiceProviderQueryHandler;
            ErrorFilterConfiguration c = new ErrorFilterConfiguration();
        }
        private static bool IsFiltered(Exception e, HttpContext context)
        {
            if (_config == null)
            {
                _config = context.GetSection("elmah/errorFilter") as ErrorFilterConfiguration
                          ?? new ErrorFilterConfiguration();
            }

            var testContext = new ErrorFilterModule.AssertionHelperContext(e, context);
            return _config.Assertion.Test(testContext);
        }
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }

            //
            // Either inherit the incoming parent configuration (for example
            // from the machine configuration file) or start with a fresh new
            // one.
            //

            ErrorFilterConfiguration config;

            if (parent != null)
            {
                ErrorFilterConfiguration parentConfig = (ErrorFilterConfiguration)parent;
                config = (ErrorFilterConfiguration)((ICloneable)parentConfig).Clone();
            }
            else
            {
                config = new ErrorFilterConfiguration();
            }

            //
            // Take the first child of <test> and turn it into the
            // assertion.
            //

            XmlElement assertionNode = (XmlElement)section.SelectSingleNode("test/*");

            if (assertionNode != null)
            {
                config.SetAssertion(AssertionFactory.Create(assertionNode));
            }

            return(config);
        }