internal static IEnumerable <IStylingRule> GetAllUnusedRules(HashSet <IStylingRule> sheetRules) { using (AmbientRuleContext.GetOrCreate()) { return(sheetRules.Intersect(UsageDataByProject.Values.SelectMany(x => x.GetUnusedRules()))); } }
public async void FinishedRecording(string operationId, string chunkContents, int chunkNumber, int chunkCount) { SessionResult result; var opId = Guid.Parse(operationId); if (_uploadHelper.TryFinishOperation(opId, chunkContents, chunkNumber, chunkCount, out result)) { lock (_operationsInProgress) { _operationsInProgress.Remove(opId); } ImportSheets(result.Sheets); using (AmbientRuleContext.GetOrCreate()) { await result.ResolveAsync(this); UsageRegistry.Merge(this, result); MessageDisplayManager.ShowWarningsFor(_connection.Url, _connection.Project, result); } } }
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); }
public static Task <IReadOnlyCollection <IStylingRule> > GetAllRulesAsync() { return(Task.Factory.StartNew(() => AmbientRuleContext.GetAllRules())); }