コード例 #1
0
        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());
            }
        }
コード例 #2
0
ファイル: UnusedCssMenu.cs プロジェクト: waodng/VSIX
 private static void ResetUsageData(object sender, EventArgs e)
 {
     DocumentFactory.Clear();
     UsageRegistry.Reset();
     MessageDisplayManager.Refresh();
     UnusedCssExtension.All(x => x.BlipRecording());
 }
コード例 #3
0
ファイル: UnusedCssMenu.cs プロジェクト: waodng/VSIX
        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);
        }
コード例 #4
0
 public SessionResult(UnusedCssExtension extension)
 {
     RawUsageData = new HashSet<RawRuleUsage>();
     _extension = extension;
     _ruleUsages = new HashSet<RuleUsage>();
     _isResolved = 1;
 }
コード例 #5
0
ファイル: RuleRegistry.cs プロジェクト: waodng/VSIX
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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();
        }
コード例 #9
0
ファイル: UsageRegistry.cs プロジェクト: waodng/VSIX
        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();
        }
コード例 #10
0
ファイル: CompositeUsageData.cs プロジェクト: waodng/VSIX
 public CompositeUsageData(UnusedCssExtension extension)
 {
     _extension = extension;
 }
コード例 #11
0
 public SessionResult(UnusedCssExtension extension)
     : this()
 {
     _extension = extension;
     _isResolved = 1;
 }
コード例 #12
0
 public CompositeUsageData(UnusedCssExtension extension)
 {
     _extension = extension;
 }
コード例 #13
0
 public SessionResult(UnusedCssExtension extension)
     : this()
 {
     _extension  = extension;
     _isResolved = 1;
 }
コード例 #14
0
ファイル: UnusedCssMenu.cs プロジェクト: waodng/VSIX
        private static void StopRecordAllBeforeQueryStatus(object sender, EventArgs e)
        {
            var menu = (OleMenuCommand)sender;

            menu.Visible = UnusedCssExtension.Any(x => x.IsRecording);
        }
コード例 #15
0
ファイル: UnusedCssMenu.cs プロジェクト: waodng/VSIX
 private static void StopRecordAll(object sender, EventArgs e)
 {
     UnusedCssExtension.All(x => x.EnsureRecordingMode(false));
 }