当前位置: 首页>>代码示例>>C#>>正文


C# ICssCheckerContext.GetState方法代码示例

本文整理汇总了C#中ICssCheckerContext.GetState方法的典型用法代码示例。如果您正苦于以下问题:C# ICssCheckerContext.GetState方法的具体用法?C# ICssCheckerContext.GetState怎么用?C# ICssCheckerContext.GetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICssCheckerContext的用法示例。


在下文中一共展示了ICssCheckerContext.GetState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            RuleSet rule = (RuleSet)item;

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

            List<RuleResult> cache = context.GetState(this) as List<RuleResult>;

            if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent))
            {
                cache = BuildCache(rule);
                context.SetState(this, cache);
            }

            string ruleText = GetSelectorText(rule);
            int start = rule.Start;
            RuleResult dupe = null;
            for (int i = 0; i < cache.Count; i++)
            {
                if (cache[i].Start >= start)
                    break;

                if (ruleText == cache[i].Value)
                {
                    dupe = cache[i];
                    break;
                }
            }            

            if (dupe != null)
            {

                int lineNo = FindLineNumber(dupe);

                string errorMessage = string.Format(CultureInfo.InvariantCulture, Resources.BestPracticeDuplicateSelectors, lineNo);
                SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors, errorMessage);
                context.AddError(tag);
            }

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

示例2: CheckItem

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

            RuleSet rule = (RuleSet)item;

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

            List<RuleResult> cache = context.GetState(this) as List<RuleResult>;

            if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent))
            {
                cache = BuildCache(rule);
                context.SetState(this, cache);
            }

            string ruleText = GetSelectorText(rule);
            int start = rule.Start;
            RuleResult dupe = null;
            for (int i = 0; i < cache.Count; i++)
            {
                if (cache[i].Start >= start)
                    break;

                if (ruleText == cache[i].Value && rule.Parent == cache[i].Rule.Parent)
                {
                    dupe = cache[i];
                    break;
                }
            }

            if (dupe != null)
            {
                SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors, "The selector " + ruleText + " is already specified earlier.  Consider combining the two rule-sets.");
                context.AddError(tag);
            }

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

示例3: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            RuleSet rule = (RuleSet)item;

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

            List<RuleResult> cache = context.GetState(this) as List<RuleResult>;

            if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent))
            {
                cache = BuildCache(rule);
                context.SetState(this, cache);
            }

            string ruleText = GetSelectorText(rule);
            int start = rule.Start;
            RuleResult dupe = null;
            for (int i = 0; i < cache.Count; i++)
            {
                if (cache[i].Start >= start)
                    break;

                if (ruleText == cache[i].Value)
                {
                    dupe = cache[i];
                    break;
                }
            }

            if (dupe != null)
            {
                SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors);
                context.AddError(tag);
            }

            return ItemCheckResult.Continue;
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:38,代码来源:DuplicateSelectorErrorTagProvider.cs


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