示例#1
0
        private StackFrameFilterDefinition GenerateDefinition(XElement element)
        {
            var definition = new StackFrameFilterDefinition();
            definition.Order = int.Parse(element.Descendants().First(x => x.Name.LocalName == "Order").Value);
            definition.FilterType = ConvertToFilterType(element.Descendants().First(x => x.Name.LocalName == "Type").Value);
            definition.RegexFilterPattern = element.Descendants().First(x => x.Name.LocalName == "RegexPattern").Value;

            return definition;
        }
示例#2
0
        public static void MockNotHigherThanApplicationCodeStackFrameFilter()
        {
            var stackFrameFilter = new StackFrameFilterDefinition();
            stackFrameFilter.FilterType = StackFrameFilterType.NotHigherThanApplicationCode;
            stackFrameFilter.Order = 1;

            var group = new StackFrameFilterGroup();
            group.Definitions.Add(stackFrameFilter);

            ContentFilterFactoryMock = new Mock<IContentFilterFactory>();
            ContentFilterFactoryMock.Setup(x => x.GenerateFilters())
                .Returns(new List<IContentFilter>() { new StackFrameFilter(group, 1) });
        }
示例#3
0
 private void FilterStackFrames(ExceptionEntity exceptionDefinition, StackFrameFilterDefinition filterDefinition)
 {
     switch (filterDefinition.FilterType)
     {
         case StackFrameFilterType.NotHigherThanApplicationCode:
             FilterStackFramesHigherThanAppCode(exceptionDefinition);
             break;
         case StackFrameFilterType.NotLowerThanApplicationCode:
             FilterStackFramesLowerThanAppCode(exceptionDefinition);
             break;
         case StackFrameFilterType.RegexPattern:
             ApplyRegexFilter(exceptionDefinition, filterDefinition);
             break;
         default:
             throw new Exception("Unsupported StackFrameFilterType");
     }
 }
示例#4
0
        private void ApplyRegexFilter(ExceptionEntity exceptionDefinition, StackFrameFilterDefinition filterDefinition)
        {
            var stackFrameRegex = new Regex(filterDefinition.RegexFilterPattern);

            var filteredStackFrames = new List<StackFrameEntity>();
            foreach (var stackFrame in exceptionDefinition.StackFrames)
            {
                if(!stackFrameRegex.IsMatch(stackFrame.Path))
                    filteredStackFrames.Add(stackFrame);
            }

            exceptionDefinition.StackFrames = filteredStackFrames;
        }