示例#1
0
        public static async Task <HashSet <RuleUsage> > ResolveAsync(IEnumerable <RawRuleUsage> rawUsageData)
        {
            var allRules = await GetAllRulesAsync();

            var result = new HashSet <RuleUsage>();

            foreach (var dataPoint in rawUsageData)
            {
                var selector  = StandardizeSelector(dataPoint.Selector);
                var locations = new HashSet <SourceLocation>(dataPoint.SourceLocations.Where(x => x != null));

                foreach (var match in allRules.Where(x => x.IsMatch(selector)))
                {
                    var ruleUsage = new RuleUsage
                    {
                        Rule = match
                    };

                    ruleUsage.SourceLocations.UnionWith(locations);
                    result.Add(ruleUsage);
                }
            }

            return(result);
        }
示例#2
0
        internal static HashSet <RuleUsage> Resolve(IEnumerable <RawRuleUsage> rawUsageData)
        {
            var allRules = AmbientRuleContext.GetAllRules();
            var result   = new HashSet <RuleUsage>();

            foreach (var dataPoint in rawUsageData)
            {
                var selector  = StandardizeSelector(dataPoint.Selector);
                var locations = new HashSet <SourceLocation>(dataPoint.SourceLocations.Where(x => x != null));

                foreach (var match in allRules.Where(x => x.IsMatch(selector)))
                {
                    var ruleUsage = new RuleUsage
                    {
                        Rule = match
                    };

                    ruleUsage.SourceLocations.UnionWith(locations);
                    result.Add(ruleUsage);
                }
            }

            return(result);
        }