• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CssItemCollector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CssItemCollector的典型用法代码示例。如果您正苦于以下问题:C# CssItemCollector类的具体用法?C# CssItemCollector怎么用?C# CssItemCollector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CssItemCollector类属于命名空间,在下文中一共展示了CssItemCollector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddMissingStandardDeclaration

        private string AddMissingStandardDeclaration(StringBuilder sb, CssEditorDocument doc, ICssSchemaInstance rootSchema)
        {
            var visitor = new CssItemCollector<RuleBlock>(true);
            doc.Tree.StyleSheet.Accept(visitor);

            //var items = visitor.Items.Where(d => d.IsValid && d.IsVendorSpecific());
            foreach (RuleBlock rule in visitor.Items.Reverse())
            {
                HashSet<string> list = new HashSet<string>();
                foreach (Declaration dec in rule.Declarations.Where(d => d.IsValid && d.IsVendorSpecific()).Reverse())
                {
                    ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaForItem(rootSchema, dec);
                    ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(dec, schema);

                    if (entry != null && !list.Contains(entry.DisplayText) && !rule.Declarations.Any(d => d.PropertyName != null && d.PropertyName.Text == entry.DisplayText))
                    {
                        int index = dec.Text.IndexOf(":", StringComparison.Ordinal);
                        string standard = entry.DisplayText + dec.Text.Substring(index);

                        sb.Insert(dec.AfterEnd, standard);
                        list.Add(entry.DisplayText);
                    }
                }
            }

            return sb.ToString();
        }
开发者ID:jonantoine,项目名称:WebEssentials2012,代码行数:27,代码来源:CssAddMissingStandardCommandTarget.cs


示例2: GetListEntries

        public IEnumerable<ICssCompletionListEntry> GetListEntries(CssCompletionContext context)
        {
            if (!IsFontFamilyContext(context))
                yield break;

            StyleSheet stylesheet = context.ContextItem.StyleSheet;
            var visitorRules = new CssItemCollector<FontFaceDirective>();
            stylesheet.Accept(visitorRules);

            foreach (FontFaceDirective item in visitorRules.Items)
            {
                var visitorDec = new CssItemCollector<Declaration>();
                item.Block.Accept(visitorDec);

                Declaration family = visitorDec.Items.FirstOrDefault(i => i.PropertyName.Text == "font-family");

                if (family != null)
                {
                    string value = string.Join(string.Empty, family.Values.Select(v => v.Text));
                    yield return new FontFamilyCompletionListEntry(value.Trim('\'', '"'));
                }
            }

            yield return new FontFamilyCompletionListEntry("Pick from file...");
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:25,代码来源:FontCompletionProvider.cs


示例3: ParseDocument

        private async static Task ParseDocument()
        {
            string fileName = GetSolutionFilePath();

            if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
            {
                CssParser parser = new CssParser();
                StyleSheet stylesheet = parser.Parse(await FileHelpers.ReadAllTextRetry(fileName), false);

                if (stylesheet.IsValid)
                {
                    var visitor = new CssItemCollector<AtDirective>();
                    stylesheet.Accept(visitor);

                    AtDirective at = visitor.Items.SingleOrDefault(a => a.Keyword.Text == _rootDirective);
                    if (at != null)
                    {
                        var visitorPalette = new CssItemCollector<AtDirective>(true);
                        at.Accept(visitorPalette);
                        _directives = visitorPalette.Items.Where(a => a.Keyword.Text != at.Keyword.Text).ToList();
                    }
                }

                InitializeWatcher(fileName);
            }
            else
            {
                _hasFile = false;
            }
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:30,代码来源:XmlColorPaletteProvider.cs


示例4: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (!WESettings.Instance.Css.ValidateVendorSpecifics)
                return ItemCheckResult.Continue;

            AtDirective directive = (AtDirective)item;

            if (context == null || !directive.IsValid || !directive.IsVendorSpecific())
                return ItemCheckResult.Continue;

            ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(directive, context);

            if (entry != null)
            {
                var visitor = new CssItemCollector<AtDirective>();
                directive.Parent.Accept(visitor);

                if (!visitor.Items.Any(a => a != null && a.Keyword != null && "@" + a.Keyword.Text == entry.DisplayText))
                {
                    string message = string.Format(CultureInfo.InvariantCulture, Resources.BestPracticeAddMissingStandardDirective, entry.DisplayText);
                    context.AddError(new SimpleErrorTag(directive.Keyword, message));
                    return ItemCheckResult.CancelCurrentItem;
                }
            }

            return ItemCheckResult.Continue;
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:27,代码来源:MissingStandardDirectiveErrorTagProvider.cs


示例5: AddMissingVendorDeclarations

        private static string AddMissingVendorDeclarations(StringBuilder sb, CssEditorDocument doc, ICssSchemaInstance rootSchema, out int count)
        {
            var visitor = new CssItemCollector<Declaration>(true);
            doc.Tree.StyleSheet.Accept(visitor);
            count = 0;

            var items = visitor.Items.Where(d => d.IsValid && !d.IsVendorSpecific() && d.PropertyName.Text != "filter");

            foreach (Declaration dec in items.Reverse())
            {
                ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaForItem(rootSchema, dec);
                var missingEntries = dec.GetMissingVendorSpecifics(schema);

                if (missingEntries.Any())
                {
                    var missingPrefixes = missingEntries.Select(e => e.Substring(0, e.IndexOf('-', 1) + 1));
                    string vendors = GetVendorDeclarations(missingPrefixes, dec);

                    sb.Insert(dec.Start, vendors);
                    count++;
                }
            }

            return sb.ToString();
        }
开发者ID:vikramgoudr,项目名称:WebEssentials2013,代码行数:25,代码来源:CssAddVendorStandardCommandTarget.cs


示例6: FindRuleSetInFile

        private string FindRuleSetInFile(IEnumerable<string> extensions, string className, out RuleSet rule)
        {
            string root = ProjectHelpers.GetProjectFolder(peekableItem._textbuffer.GetFileName());
            string result = null;
            bool isLow = false, isMedium = false;
            rule = null;

            foreach (string ext in extensions)
            {
                ICssParser parser = CssParserLocator.FindComponent(Mef.GetContentType(ext.Trim('.'))).CreateParser();

                foreach (string file in Directory.EnumerateFiles(root, "*" + ext, SearchOption.AllDirectories))
                {
                    if (file.EndsWith(".min" + ext, StringComparison.OrdinalIgnoreCase) ||
                        file.Contains("node_modules") ||
                        file.Contains("bower_components"))
                        continue;

                    string text = FileHelpers.ReadAllTextRetry(file).ConfigureAwait(false).GetAwaiter().GetResult();
                    int index = text.IndexOf("." + className, StringComparison.Ordinal);

                    if (index == -1)
                        continue;

                    var css = parser.Parse(text, true);
                    var visitor = new CssItemCollector<ClassSelector>(false);
                    css.Accept(visitor);

                    var selectors = visitor.Items.Where(c => c.ClassName.Text == className);
                    var high = selectors.FirstOrDefault(c => c.FindType<AtDirective>() == null && (c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ","));

                    if (high != null)
                    {
                        rule = high.FindType<RuleSet>();
                        return file;
                    }

                    var medium = selectors.FirstOrDefault(c => c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ",");

                    if (medium != null && !isMedium)
                    {
                        rule = medium.FindType<RuleSet>();
                        result = file;
                        isMedium = true;
                        continue;
                    }

                    var low = selectors.FirstOrDefault();

                    if (low != null && !isLow && !isMedium)
                    {
                        rule = low.FindType<RuleSet>();
                        result = file;
                        isLow = true;
                    }
                }
            }

            return result;
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:60,代码来源:ClassPeekResultSource.cs


示例7: Calculate

        private void Calculate()
        {
            // IDs
            var visitorIDs = new CssItemCollector<IdSelector>();
            _selector.Accept(visitorIDs);

            if (visitorIDs.Items.Count > 0)
                IDs = visitorIDs.Items.Count;// *100;

            // Classes
            var visitorClasses = new CssItemCollector<ClassSelector>();
            _selector.Accept(visitorClasses);

            if (visitorClasses.Items.Count > 0)
                Classes = visitorClasses.Items.Count;// *10;

            // Attributes
            var visitorAttribute = new CssItemCollector<AttributeSelector>();
            _selector.Accept(visitorAttribute);

            if (visitorAttribute.Items.Count > 0)
                Attributes = visitorAttribute.Items.Count;// *10;

            // Elements
            var visitorElements = new CssItemCollector<ItemName>();
            _selector.Accept(visitorElements);
            Elements = visitorElements.Items.Where(i => i.Text != "*" && i.FindType<AttributeSelector>() == null).Count();

            // Pseudo Elements
            var visitorPseudoElementSelector = new CssItemCollector<PseudoElementSelector>();
            _selector.Accept(visitorPseudoElementSelector);

            var visitorPseudoElementFunctionSelector = new CssItemCollector<PseudoElementFunctionSelector>();
            _selector.Accept(visitorPseudoElementFunctionSelector);

            PseudoElements = visitorPseudoElementSelector.Items.Count + visitorPseudoElementFunctionSelector.Items.Count;

            // Pseudo Classes
            var visitorPseudoClassSelector = new CssItemCollector<PseudoClassSelector>();
            _selector.Accept(visitorPseudoClassSelector);

            var visitorPseudoClassFunctionSelector = new CssItemCollector<PseudoClassFunctionSelector>(true);
            _selector.Accept(visitorPseudoClassFunctionSelector);

            int pseudoClases = visitorPseudoClassSelector.Items.Count(p => !p.IsPseudoElement());
            pseudoClases += visitorPseudoClassFunctionSelector.Items.Where(p => !p.Text.StartsWith(":not(") && !p.Text.StartsWith(":matches(")).Count();
            Elements += visitorPseudoClassSelector.Items.Count(p => p.IsPseudoElement());

            if (pseudoClases > 0)
                PseudoClasses = pseudoClases;// *10;

            // Total
            //Total = IDs + Classes + Attributes + Elements + PseudoElements + PseudoClasses;
        }
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:54,代码来源:SelectorSpecificity.cs


示例8: GetListEntries

        public IEnumerable<ICssCompletionListEntry> GetListEntries(CssCompletionContext context)
        {
            var visitor = new CssItemCollector<Declaration>();
            context.ContextItem.StyleSheet.Accept(visitor);

            foreach (Declaration dec in visitor.Items)
            {
                if (dec.IsValid && dec.PropertyName.Text.StartsWith("var-"))
                    yield return new CompletionListEntry(dec.PropertyName.Text.Substring(4));
            }
        }
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:11,代码来源:VariableNameCompletionProvider.cs


示例9: GetListEntries

        public IEnumerable<ICssCompletionListEntry> GetListEntries(CssCompletionContext context)
        {
            StyleSheet stylesheet = context.ContextItem.StyleSheet;
            var visitorRules = new CssItemCollector<ClassSelector>();
            stylesheet.Accept(visitorRules);

            foreach (string item in visitorRules.Items.Where(s => s != context.ContextItem).Select(s => s.Text).Distinct())
            {
                yield return new CompletionListEntry(item);
            }
        }
开发者ID:kodybrown,项目名称:WebEssentials2013,代码行数:11,代码来源:ClassCompletionProvider.cs


示例10: UpdateCache

        private void UpdateCache(ParseItem item)
        {
            var visitor = new CssItemCollector<Declaration>(true);
            item.Accept(visitor);

            foreach (TokenItem token in visitor.Items.Where(d => d.Important != null).Select(d => d.Important))
            {
                if (!_cache.Contains(token))
                    _cache.Add(token);
            }
        }
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:11,代码来源:ImportantClassifier.cs


示例11: GetMissingVendorSpecifics

        public static IEnumerable<string> GetMissingVendorSpecifics(this AtDirective directive, ICssSchemaInstance schema)
        {
            IEnumerable<string> possible = GetPossibleVendorSpecifics(directive, schema);

            var visitorRules = new CssItemCollector<AtDirective>();
            directive.Parent.Accept(visitorRules);

            foreach (string item in possible)
            {
                if (!visitorRules.Items.Any(d => d.Keyword != null && "@" + d.Keyword.Text == item))
                    yield return item;
            }
        }
开发者ID:alexdresko,项目名称:WebEssentials2013,代码行数:13,代码来源:AtDirectiveExtensions.cs


示例12: InitializeCache

        private void InitializeCache(StyleSheet stylesheet)
        {
            _cache.Clear();

            var visitor = new CssItemCollector<Declaration>(true);
            stylesheet.Accept(visitor);

            foreach (Declaration dec in visitor.Items.Where(d => d.PropertyName != null))
            {
                if (dec.PropertyName.Text == "display" && dec.Values.Any(v => v.Text == "inline"))
                    _cache.Add(dec);
            }
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:13,代码来源:DisplayInlineErrorTagProvider.cs


示例13: BuildCache

        private List<RuleResult> BuildCache(RuleSet rule)
        {
            var visitor = new CssItemCollector<RuleSet>();
            rule.Parent.Accept(visitor);
            List<RuleResult> list = new List<RuleResult>();

            foreach (RuleSet rs in visitor.Items)
            {
                RuleResult result = new RuleResult(rs, rs.Start, GetSelectorText(rs));
                list.Add(result);
            }

            return list;
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:14,代码来源:DuplicateSelectorErrorTagProvider.cs


示例14: UpdateCache

        private void UpdateCache(ParseItem item)
        {
            var visitor = new CssItemCollector<Declaration>(true);
            item.Accept(visitor);

            foreach (Declaration dec in visitor.Items)
            {
                string text = dec.Text;

                if (text.StartsWith("var-", StringComparison.Ordinal))
                {
                    if (!_cache.Contains(dec))
                        _cache.Add(dec);
                }
            }
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:16,代码来源:VariableClassifier.cs


示例15: UpdateCache

        private void UpdateCache(ParseItem item)
        {
            var visitor = new CssItemCollector<SimpleSelector>(true);
            item.Accept(visitor);

            foreach (SimpleSelector ss in visitor.Items)
            {
                string text = ss.Text;

                if (ModernizrProvider.IsModernizr(text))
                {
                    if (!_cache.Contains(ss))
                        _cache.Add(ss);
                }
            }
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:16,代码来源:ModernizrClassifier.cs


示例16: GetListEntries

        public IEnumerable<ICssCompletionListEntry> GetListEntries(CssCompletionContext context)
        {
            Declaration dec = context.ContextItem.FindType<Declaration>();

            if (dec == null || dec.PropertyName == null || (!dec.PropertyName.Text.EndsWith("animation-name", StringComparison.OrdinalIgnoreCase) && dec.PropertyName.Text != "animation"))
                yield break;

            StyleSheet stylesheet = context.ContextItem.StyleSheet;
            var visitor = new CssItemCollector<KeyFramesDirective>();
            stylesheet.Accept(visitor);

            foreach (string name in visitor.Items.Select(d => d.Name.Text).Distinct(StringComparer.OrdinalIgnoreCase))
            {
                yield return new CompletionListEntry(name);
            }
        }
开发者ID:Gordon-Beeming,项目名称:WebEssentials2013,代码行数:16,代码来源:AnimationNameCompletionProvider.cs


示例17: GetSmartTagActions

        public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
        {
            AtDirective directive = (AtDirective)item;

            if (!item.IsValid || !directive.IsVendorSpecific())
                yield break;

            ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaRootForBuffer(view.TextBuffer);
            var visitor = new CssItemCollector<AtDirective>();
            directive.Parent.Accept(visitor);

            ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(directive, schema);
            if (entry != null && !visitor.Items.Any(d => d.Keyword != null && "@" + d.Keyword.Text == entry.DisplayText))
            {
                yield return new MissingStandardDirectiveSmartTagAction(itemTrackingSpan, directive, entry.DisplayText);
            }
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:17,代码来源:MissingStandardDirectiveSmartTagProvider.cs


示例18: RemoveDuplicateProperties

        private static string RemoveDuplicateProperties(StringBuilder sb, CssEditorDocument doc)
        {
            var visitor = new CssItemCollector<RuleBlock>(true);
            doc.Tree.StyleSheet.Accept(visitor);

            foreach (RuleBlock rule in visitor.Items.Reverse())
            {
                HashSet<string> list = new HashSet<string>();

                foreach (Declaration dec in rule.Declarations.Reverse())
                {
                    if (!list.Add(dec.Text))
                        sb.Remove(dec.Start, dec.Length);
                }
            }

            return sb.ToString();
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:18,代码来源:CssRemoveDuplicatesCommandTarget.cs


示例19: GetListEntries

        public IEnumerable<ICssCompletionListEntry> GetListEntries(CssCompletionContext context)
        {
            HashSet<ICssCompletionListEntry> entries = new HashSet<ICssCompletionListEntry>();
            Declaration dec = context.ContextItem.FindType<Declaration>();

            if (dec == null || dec.PropertyName == null || (!dec.PropertyName.Text.EndsWith("animation-name", StringComparison.OrdinalIgnoreCase) && dec.PropertyName.Text != "animation"))
                return entries;

            StyleSheet stylesheet = context.ContextItem.StyleSheet;
            var visitor = new CssItemCollector<KeyFramesDirective>();
            stylesheet.Accept(visitor);

            foreach (KeyFramesDirective keyframes in visitor.Items)
            {
                if (!entries.Any(e => e.DisplayText.Equals(keyframes.Name.Text, StringComparison.OrdinalIgnoreCase)))
                    entries.Add(new CompletionListEntry(keyframes.Name.Text));
            }

            return entries;
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:20,代码来源:AnimationNameCompletionProvider.cs


示例20: GetListEntries

        public IEnumerable<ICssCompletionListEntry> GetListEntries(CssCompletionContext context)
        {
            HashSet<string> classNames = new HashSet<string>();
            HashSet<ICssCompletionListEntry> entries = new HashSet<ICssCompletionListEntry>();
            
            StyleSheet stylesheet = context.ContextItem.StyleSheet;
            var visitorRules = new CssItemCollector<ClassSelector>();
            stylesheet.Accept(visitorRules);

            foreach (ClassSelector item in visitorRules.Items)
            {
                if (item != context.ContextItem && !classNames.Contains(item.Text))
                {
                    classNames.Add(item.Text);
                    entries.Add(new CompletionListEntry(item.Text));
                }
            }

            return entries;
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:20,代码来源:ClassCompletionProvider.cs



注:本文中的CssItemCollector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CssValue类代码示例发布时间:2022-05-24
下一篇:
C# CspProviderFlags类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap