AppfailReporting.Appfail.IsFilteredByWebConfig C# (CSharp) Метод

IsFilteredByWebConfig() статический приватный Метод

static private IsFilteredByWebConfig ( Exception e, string url ) : bool
e System.Exception
url string
Результат bool
        internal static bool IsFilteredByWebConfig(Exception e, string url)
        {
            if (ConfigurationModel.Instance.IgnoreExceptionSettingsFromWebConfig.Count > 0)
            {
                foreach (var element in ConfigurationModel.Instance.IgnoreExceptionSettingsFromWebConfig)
                {
                    switch (element.Type)
                    {
                        case "HttpStatusCode":
                            {
                                var httpStatusCode = 0;

                                if (int.TryParse(element.Value, out httpStatusCode))
                                {
                                    if (e is HttpException)
                                    {
                                        var exceptionHttpStatusCode = GetHttpStatusCode(e as HttpException);

                                        if (httpStatusCode == (int)exceptionHttpStatusCode)
                                        {
                                            return true;
                                        }
                                    }
                                }

                                break;
                            }

                        case "ExceptionMessage":
                            {
                                try
                                {
                                    var regex = new Regex(element.Value);

                                    if (regex.Match(e.Message).Success)
                                    {
                                        return true; 
                                    }
                                }
                                catch (Exception regex)
                                {
                                    Debug.WriteLine(string.Format("Appfail: Could not parse or evaluate regex value - {0}" + regex.Message));
                                }

                                break;
                            }

                        case "HttpExceptionType":
                            {
                                if (string.Equals(element.Value, e.GetType().Name) || string.Equals(element.Value, e.GetType().FullName))
                                {
                                    return true;
                                }

                                break;
                            }
                        case "RelativeUrlContains":
                            {
                                return UrlHelpers.UrlContains(url, element.Value);
                            }
                        case "RelativeUrlStartsWith":
                            {
                                return UrlHelpers.UrlStartsWith(url, element.Value);
                            }
                        case "RelativeUrl":
                            {
                                return UrlHelpers.UrlsAreEqual(url, element.Value);
                            }
                    }
                }
            }


            return false;
        }