public bool IsRuleComplexityLimitExceeded(RuleComplexityData ruleComplexityData)
 {
     if (ruleComplexityData == null)
     {
         throw new ArgumentNullException("ruleComplexityData");
     }
     return(ruleComplexityData.TermsFromCustomKeywordProcessorReferencesCount > this.distinctTermsFromCustomKeywordProcessorRefsCountLimit);
 }
 public bool IsRuleComplexityLimitExceeded(RuleComplexityData ruleComplexityData)
 {
     if (ruleComplexityData == null)
     {
         throw new ArgumentNullException("ruleComplexityData");
     }
     return(ruleComplexityData.AnyBlocksCount > this.anyBlocksCountLimit);
 }
Пример #3
0
 public bool IsRuleComplexityLimitExceeded(RuleComplexityData ruleComplexityData)
 {
     if (ruleComplexityData == null)
     {
         throw new ArgumentNullException("ruleComplexityData");
     }
     return(ruleComplexityData.DistinctRegexProcessorReferencesCount > this.distinctRegexProcessorReferencesCountLimit);
 }
Пример #4
0
 public bool IsRuleComplexityLimitExceeded(RuleComplexityData ruleComplexityData)
 {
     if (ruleComplexityData == null)
     {
         throw new ArgumentNullException("ruleComplexityData");
     }
     return(ruleComplexityData.MaxAnyBlocksDepth > this.nestedAnyBlocksDepthLimit);
 }
Пример #5
0
        internal static RuleComplexityData Create(XElement ruleElement, Dictionary <TextProcessorType, TextProcessorGrouping> customTextProcessorGroups, Dictionary <string, int> customKeywordProcessorsTermsCount, Dictionary <TextProcessorType, TextProcessorGrouping> oobTextProcessorGroups = null)
        {
            if (ruleElement == null)
            {
                throw new ArgumentNullException("ruleElement");
            }
            if (customTextProcessorGroups == null)
            {
                throw new ArgumentNullException("customTextProcessorGroups");
            }
            if (customKeywordProcessorsTermsCount == null)
            {
                throw new ArgumentNullException("customKeywordProcessorsTermsCount");
            }
            oobTextProcessorGroups = (oobTextProcessorGroups ?? TextProcessorUtils.OobProcessorsGroupedByType);
            List <string> list = (from versionedTextProcessorReference in TextProcessorUtils.GetTextProcessorReferences(ruleElement)
                                  select versionedTextProcessorReference.Key).Distinct(ClassificationDefinitionConstants.TextProcessorIdComparer).ToList <string>();
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            foreach (string textProcessorRef in list)
            {
                if (RuleComplexityData.IsRegexProcessorReference(textProcessorRef, oobTextProcessorGroups, customTextProcessorGroups))
                {
                    num++;
                }
                else if (RuleComplexityData.IsFunctionProcessorReference(textProcessorRef, oobTextProcessorGroups))
                {
                    num3++;
                }
                else
                {
                    num2 += RuleComplexityData.GetTermsFromCustomKeywordProcessorCount(textProcessorRef, customTextProcessorGroups, customKeywordProcessorsTermsCount);
                }
            }
            RuleComplexityData ruleComplexityData = new RuleComplexityData
            {
                DistinctRegexProcessorReferencesCount          = num,
                TermsFromCustomKeywordProcessorReferencesCount = num2,
                DistinctFunctionProcessorReferencesCount       = num3
            };

            ruleComplexityData.ProcessAnyBlocksComplexityData(ruleElement);
            return(ruleComplexityData);
        }
Пример #6
0
        private IEnumerable <KeyValuePair <string, RuleComplexityData> > GetRulePackComplexityData(XDocument rulePackXDocument)
        {
            ExAssert.RetailAssert(rulePackXDocument != null, "The rule pack document instance passed to GetRulePackComplexityData cannot be null!");
            Dictionary <TextProcessorType, TextProcessorGrouping> customTextProcessorGroups = TextProcessorUtils.GetRulePackScopedTextProcessorsGroupedByType(rulePackXDocument).ToDictionary((TextProcessorGrouping textProcessorGroup) => textProcessorGroup.Key);
            Dictionary <string, int> customKeywordProcessorsTermsCount = ComplexityValidator.GetKeywordProcessorTermsCount(rulePackXDocument);
            IEnumerable <XElement>   source = from rulePackElement in rulePackXDocument.Descendants()
                                              where ClassificationDefinitionConstants.MceRuleElementNames.Contains(rulePackElement.Name.LocalName)
                                              select rulePackElement;

            return(from ruleElement in source.AsParallel <XElement>().AsOrdered <XElement>()
                   select new KeyValuePair <string, RuleComplexityData>(ruleElement.Attribute("id").Value, RuleComplexityData.Create(ruleElement, customTextProcessorGroups, customKeywordProcessorsTermsCount, this.cannedOobTextProcessorIdsGroupedByType)));
        }