private async void Reparse(object sender, FileSystemEventArgs e) { if (e != null && e.Name.ToLowerInvariant() != _localFileName) { return; } var tryCount = 0; const int maxTries = 20; while (tryCount++ < maxTries) { try { var text = File.ReadAllText(_file); Reparse(text); break; } catch (IOException) { } await Task.Delay(100); } await UsageRegistry.ResynchronizeAsync(); if (IsProcessingUnusedCssRules) { UnusedCssExtension.All(x => x.SnapshotPage()); } }
private static void ResetUsageData(object sender, EventArgs e) { DocumentFactory.Clear(); UsageRegistry.Reset(); MessageDisplayManager.Refresh(); UnusedCssExtension.All(x => x.BlipRecording()); }
private static void RecordAllBeforeQueryStatus(object sender, EventArgs e) { var menuCommand = (OleMenuCommand)sender; menuCommand.Enabled = UnusedCssExtension.IsAnyConnectionAlive; menuCommand.Visible = menuCommand.Enabled && !UnusedCssExtension.Any(x => x.IsRecording); }
public SessionResult(UnusedCssExtension extension) { RawUsageData = new HashSet<RawRuleUsage>(); _extension = extension; _ruleUsages = new HashSet<RuleUsage>(); _isResolved = 1; }
public static IReadOnlyCollection <IStylingRule> GetAllRules() { //This lookup needs to be Project -> Browser -> Page (but page -> sheets should be tracked internally by the extension) var files = UnusedCssExtension.GetValidSheetUrls(); var allRules = new List <IStylingRule>(); foreach (var file in files) { var store = DocumentFactory.GetDocument(file.ToLowerInvariant(), true); if (store != null) { store.IsProcessingUnusedCssRules = true; var rules = store.Rules; if (rules != null) { allRules.AddRange(rules); } else { DocumentFactory.UnregisterDocument(store); } } } return(allRules); }
public async System.Threading.Tasks.Task ResolveAsync(UnusedCssExtension extension) { if (Interlocked.CompareExchange(ref _isResolved, 1, 0) == 1) { throw new InvalidOperationException("Data source has already been resolved"); } _extension = extension; _ruleUsages = await RuleRegistry.ResolveAsync(RawUsageData); }
public static void Merge(UnusedCssExtension extension, SessionResult source) { var url = extension.Connection.Url.ToString().ToLowerInvariant(); var crossBrowserPageBucket = UsageDataByLocation.GetOrAdd(url, location => new SessionResult(extension)); var connectionSiteBucket = UsageDataByConnectionAndLocation.GetOrAdd(extension.Connection, conn => new ConcurrentDictionary<string, SessionResult>()); var connectionPageBucket = connectionSiteBucket.GetOrAdd(url, location => new SessionResult(extension)); var projectBucket = UsageDataByProject.GetOrAdd(extension.Connection.Project.UniqueName, proj => new SessionResult(extension)); crossBrowserPageBucket.Merge(source); connectionPageBucket.Merge(source); projectBucket.Merge(source); OnUsageDataUpdated(); }
public static void Merge(UnusedCssExtension extension, SessionResult source) { var url = extension.Connection.Url.ToString().ToLowerInvariant(); var crossBrowserPageBucket = UsageDataByLocation.GetOrAdd(url, location => new SessionResult(extension)); var connectionSiteBucket = UsageDataByConnectionAndLocation.GetOrAdd(extension.Connection, conn => new ConcurrentDictionary <string, SessionResult>()); var connectionPageBucket = connectionSiteBucket.GetOrAdd(url, location => new SessionResult(extension)); var projectBucket = UsageDataByProject.GetOrAdd(extension.Connection.Project.UniqueName, proj => new SessionResult(extension)); crossBrowserPageBucket.Merge(source); connectionPageBucket.Merge(source); projectBucket.Merge(source); OnUsageDataUpdated(); }
public CompositeUsageData(UnusedCssExtension extension) { _extension = extension; }
public SessionResult(UnusedCssExtension extension) : this() { _extension = extension; _isResolved = 1; }
private static void StopRecordAllBeforeQueryStatus(object sender, EventArgs e) { var menu = (OleMenuCommand)sender; menu.Visible = UnusedCssExtension.Any(x => x.IsRecording); }
private static void StopRecordAll(object sender, EventArgs e) { UnusedCssExtension.All(x => x.EnsureRecordingMode(false)); }