本文整理汇总了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;
}
示例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;
}
示例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;
}