示例#1
0
        private CssRule(string sourceFile, string fileText, RuleSet ruleSet, string selectorName)
        {
            SelectorName         = selectorName;
            CleansedSelectorName = RuleRegistry.StandardizeSelector(SelectorName);
            DisplaySelectorName  = SelectorName.Replace('\r', '\n').Replace("\n", "").Trim();

            string oldDisplaySelectorName = null;

            while (DisplaySelectorName != oldDisplaySelectorName)
            {
                oldDisplaySelectorName = DisplaySelectorName;
                DisplaySelectorName    = DisplaySelectorName.Replace("  ", " ");
            }

            File = sourceFile;

            int line, column;

            CalculateLineAndColumn(fileText, ruleSet, out line, out column);
            Line   = line;
            Column = column;
            Offset = ruleSet.Range.Start;
            Length = ruleSet.Range.Length;

            var lastSelector = ruleSet.Selectors[ruleSet.Selectors.Count - 1];

            SelectorLength = lastSelector.Length + lastSelector.Start - ruleSet.Selectors[0].Start;
            _ruleSet       = ruleSet;
        }
示例#2
0
        public static bool IsAProtectedClass(IStylingRule rule)
        {
            var selectorName = rule.DisplaySelectorName;
            var cleansedName = RuleRegistry.StandardizeSelector(selectorName);

            return(cleansedName.IndexOf(":visited", StringComparison.Ordinal) > -1 || cleansedName.IndexOf(":hover", StringComparison.Ordinal) > -1 || cleansedName.IndexOf(":active", StringComparison.Ordinal) > -1);
        }
示例#3
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);
        }
示例#4
0
 public async System.Threading.Tasks.Task ResyncAsync()
 {
     _ruleUsages = await RuleRegistry.ResolveAsync(RawUsageData);
 }
示例#5
0
 public void Resync()
 {
     _ruleUsages = RuleRegistry.Resolve(RawUsageData);
 }
示例#6
0
 public void Update()
 {
     Rules = RuleRegistry.GetAllRules();
 }