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


C# ICssCheckerContext类代码示例

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


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

示例1: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (item.Text.TrimStart(':').StartsWith("-"))
                return ItemCheckResult.Continue;

            ParseItem next = item.NextSibling;
            //ParseItem prev = item.PreviousSibling;
            SimpleSelector sel = item.FindType<SimpleSelector>();

            //if (item.Text == ":hover" && prev != null && _invalids.Contains(prev.Text))
            //{
            //    string error = string.Format(Resources.ValidationHoverOrder, prev.Text);
            //    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
            //}

            if (next != null)
            {
                if (next.Text.StartsWith(":") && item.IsPseudoElement() && !next.IsPseudoElement())
                {
                    string error = string.Format(Resources.ValidationPseudoOrder, item.Text, next.Text);
                    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
                }

                else if (!next.Text.StartsWith(":") && item.AfterEnd == next.Start)
                {
                    string error = string.Format(Resources.BestPracticePseudosAfterOtherSelectors, next.Text);
                    context.AddError(new SimpleErrorTag(next, error));
                }
            }

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

示例2: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            UrlItem url = (UrlItem)item;

            if (!WESettings.GetBoolean(WESettings.Keys.ValidateEmbedImages) || !url.IsValid || url.UrlString.Text.Contains("base64,") || context == null)
                return ItemCheckResult.Continue;

            string fileName = ImageQuickInfo.GetFullUrl(url.UrlString.Text, EditorExtensionsPackage.DTE.ActiveDocument.FullName);
            if (string.IsNullOrEmpty(fileName) || fileName.Contains("://"))
                return ItemCheckResult.Continue;

            FileInfo file = new FileInfo(fileName);

            if (file.Exists && file.Length < (1024 * 3))
            {
                Declaration dec = url.FindType<Declaration>();
                if (dec != null && dec.PropertyName != null && dec.PropertyName.Text[0] != '*' && dec.PropertyName.Text[0] != '_')
                {
                    string error = string.Format(Resources.PerformanceEmbedImageAsDataUri, file.Length);
                    context.AddError(new SimpleErrorTag(url.UrlString, error));
                }
            }

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

示例3: CheckItem

        //private HashSet<string> _deprecated = new HashSet<string>()
        //{
        //    "-moz-opacity",
        //    "-moz-outline",
        //    "-moz-outline-style",
        //};
        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.ValidateVendorSpecifics))
                return ItemCheckResult.Continue;

            Declaration dec = (Declaration)item;

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

            ICssSchemaInstance rootSchema = CssSchemaManager.SchemaManager.GetSchemaRoot(null);
            ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaForItem(rootSchema, item);

            //if (_deprecated.Contains(dec.PropertyName.Text))
            //{
            //    string message = string.Format(Resources.ValidationDeprecatedVendorDeclaration, dec.PropertyName.Text);
            //    context.AddError(new SimpleErrorTag(dec.PropertyName, message));
            //    return ItemCheckResult.CancelCurrentItem;
            //}
             if (schema.GetProperty(dec.PropertyName.Text) == null)
            {
                string message = string.Format(Resources.ValidationVendorDeclarations, dec.PropertyName.Text);
                context.AddError(new SimpleErrorTag(dec.PropertyName, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                return ItemCheckResult.CancelCurrentItem;
            }

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

示例4: HandleDeclaration

        private static void HandleDeclaration(ParseItem item, ICssCheckerContext context)
        {
            Declaration dec = (Declaration)item;

            if (dec == null || dec.PropertyName == null)
                return;

            if (dec.IsVendorSpecific())
            {
                string message = string.Format("Validation (W3C): \"{0}\" is not a valid W3C property", dec.PropertyName.Text);
                context.AddError(new SimpleErrorTag(dec.PropertyName, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
            }

            foreach (var value in dec.Values)
            {
                string text = value.Text;
                if (!(value is NumericalValue) && text.StartsWith("-", StringComparison.Ordinal))
                {
                    int index = text.IndexOf('(');

                    if (index > -1)
                    {
                        text = text.Substring(0, index);
                    }

                    string message = string.Format("Validation (W3C): \"{0}\" is not a valid W3C value", text);
                    context.AddError(new SimpleErrorTag(value, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                }
            }
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:30,代码来源:W3cOnlyErrorTagProvider.cs

示例5: 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

示例6: CheckItem

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

            Declaration dec = (Declaration)item;

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

            ICssSchemaInstance rootSchema = CssSchemaManager.SchemaManager.GetSchemaRoot(null);
            ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaForItem(rootSchema, item);

            ICssCompletionListEntry prop = schema.GetProperty(dec.PropertyName.Text);

            if (prop == null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, Resources.ValidationVendorDeclarations, dec.PropertyName.Text);
                context.AddError(new SimpleErrorTag(dec.PropertyName, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                return ItemCheckResult.CancelCurrentItem;
            }
            else
            {
                string obsolete = prop.GetAttribute("obsolete");
                if (!string.IsNullOrEmpty(obsolete))
                {
                    string message = string.Format(CultureInfo.CurrentCulture, Resources.BestPracticeRemoveObsolete, dec.PropertyName.Text, obsolete);
                    context.AddError(new SimpleErrorTag(dec.PropertyName, message, CssErrorFlags.TaskListMessage));
                    return ItemCheckResult.CancelCurrentItem;
                }
            }

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

示例7: CheckItem

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

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

            IEnumerable<string> properties = from d in rule.Declarations
                                             where d.PropertyName != null && d.Values.Count < 2
                                             select d.PropertyName.Text;


            foreach (string shorthand in _cache.Keys)
            {
                if (_cache[shorthand].All(p => properties.Contains(p)))
                {
                    Declaration dec = rule.Declarations.First(p => p.PropertyName != null && _cache[shorthand].Contains(p.PropertyName.Text));
                    string message = string.Format(CultureInfo.CurrentCulture, Resources.PerformanceUseShorthand, string.Join(", ", _cache[shorthand]), shorthand);

                    context.AddError(new SimpleErrorTag(dec, message));
                }
            }

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

示例8: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.ValidateZeroUnit))
                return ItemCheckResult.Continue;

            NumericalValue number = (NumericalValue)item;
            UnitValue unit = number as UnitValue;

            if (unit == null || context == null)
                return ItemCheckResult.Continue;

            // The 2nd and 3rd arguments to hsl() require units even when zero
            var function = unit.Parent.Parent as FunctionColor;
            if (function != null && function.FunctionName.Text.StartsWith("hsl", StringComparison.OrdinalIgnoreCase)) {
                var arg = unit.Parent as FunctionArgument;
                if (arg != function.Arguments[0])
                    return ItemCheckResult.Continue;
            }

            if (number.Number.Text == "0" && unit.UnitType != UnitType.Unknown && unit.UnitType != UnitType.Time)
            {
                string message = string.Format(Resources.BestPracticeZeroUnit, unit.UnitToken.Text);
                context.AddError(new SimpleErrorTag(number, message));
            }

            return ItemCheckResult.Continue;
        }
开发者ID:ncl-dmoreira,项目名称:WebEssentials2013,代码行数:27,代码来源:ZeroUnitErrorTagProvider.cs

示例9: CheckItem

        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            UrlItem url = (UrlItem)item;

            if (!WESettings.Instance.Css.ValidateEmbedImages || !url.IsValid || url.UrlString == null || url.UrlString.Text.Contains("base64,") || context == null)
                return ItemCheckResult.Continue;

            string fileName = ImageQuickInfo.GetFullUrl(url.UrlString.Text, WebEssentialsPackage.DTE.ActiveDocument.FullName);
            if (string.IsNullOrEmpty(fileName) || fileName.Contains("://"))
                return ItemCheckResult.Continue;

            // Remove parameters if any; c:/temp/myfile.ext?#iefix
            fileName = fileName.Split('?', '#')[0];

            try
            {
                FileInfo file = new FileInfo(fileName);

                if (file.Exists && file.Length < (1024 * 3))
                {
                    Declaration dec = url.FindType<Declaration>();
                    if (dec != null && dec.PropertyName != null && dec.PropertyName.Text[0] != '*' && dec.PropertyName.Text[0] != '_')
                    {
                        string error = string.Format(CultureInfo.CurrentCulture, Resources.PerformanceEmbedImageAsDataUri, file.Length);
                        context.AddError(new SimpleErrorTag(url.UrlString, error));
                    }
                }
            }
            catch { /* Ignore any error here */ }

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

示例10: FilterErrorList

        public void FilterErrorList(IList<ICssError> errors, ICssCheckerContext context)
        {
            Document doc = EditorExtensionsPackage.DTE.ActiveDocument;
            if (doc == null || string.IsNullOrEmpty(doc.FullName) || !doc.FullName.EndsWith(".scss", StringComparison.OrdinalIgnoreCase))
                return;

            errors.Clear();
        }
开发者ID:Nangal,项目名称:WebEssentials2013,代码行数:8,代码来源:SassErrorFilter.cs

示例11: HandlePseudo

        private static void HandlePseudo(ParseItem item, ICssCheckerContext context)
        {
            string text = item.Text.TrimStart(':');

            if (text.StartsWith("-", StringComparison.Ordinal))
            {
                string message = string.Format("Validation (W3C): \"{0}\" is not a valid W3C pseudo class/element", item.Text);
                context.AddError(new SimpleErrorTag(item, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
            }
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:10,代码来源:W3cOnlyErrorTagProvider.cs

示例12: ValidateHsl

        private static void ValidateHsl(ICssCheckerContext context, FunctionColor function)
        {
            ParseItem argument;
            string text = "";
            string[] pair;
            int argumentCount = function.Arguments.Count;
            int value;

            if (function.FunctionName.Text.StartsWith("hsla", StringComparison.OrdinalIgnoreCase) && argumentCount < 4)
            {
                context.AddError(new SimpleErrorTag(function.Arguments[2], "Validation: HSLA expects alpha value between 0 and 1 as fourth parameter", CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
            }

            for (int i = 0; i < argumentCount; i++)
            {
                argument = function.Arguments[i];
                text = argument.Text.Trim(',');

                if (i < 3)
                {
                    pair = text.Split('%');

                    if (pair.Length > 1 || pair[0].IsNumeric())
                    {
                        context.AddError(new SimpleErrorTag(argument, "Validation: Invalid value", CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                    }

                    if (!int.TryParse(pair[0], out value))
                    {
                        context.AddError(new SimpleErrorTag(argument, "Validation: Missing value", CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                    }

                    else
                    {
                        if (value < 0 || value > 100)
                        {
                            context.AddError(new SimpleErrorTag(argument, "Validation: Values must be between 0 and 100%", CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                        }

                        if (i > 0 && value > 0 && pair[1] == "%")
                        {
                            context.AddError(new SimpleErrorTag(argument, "Validation: Parameter missing the % unit", CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                        }
                    }
                }
                else if (function.FunctionName.Text.StartsWith("hsla", StringComparison.OrdinalIgnoreCase))
                {
                    ValidateAlphaValue(context, argument, text);
                }
                else
                {
                    context.AddError(new SimpleErrorTag(argument, "Validation: HSL cannot have fourth parameter. Are you confusing HSL with HSLA?", CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
                }
            }
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:55,代码来源:ColorValuesInRangeErrorTagProvider.cs

示例13: GetMatchingStandardEntry

        public static ICssCompletionListEntry GetMatchingStandardEntry(Declaration declaration, ICssCheckerContext context)
        {
            string standardName;
            if (declaration.TryGetStandardPropertyName(out standardName, CssEditorChecker.GetSchemaForItem(context, declaration)))
            {
                ICssSchemaInstance schema = CssEditorChecker.GetSchemaForItem(context, declaration);
                return schema.GetProperty(standardName);
            }

            return null;
        }
开发者ID:jonantoine,项目名称:WebEssentials2012,代码行数:11,代码来源:VendorHelpers.cs

示例14: FilterErrorList

 public void FilterErrorList(IList<ICssError> errors, ICssCheckerContext context)
 {
     for (int i = errors.Count - 1; i > -1; i--)
     {
         ICssError error = errors[i];
         
         if (error.Item.StyleSheet is LessStyleSheet && error.Text.Contains(":extend("))
         {
             errors.RemoveAt(i);                
         }
     }
 }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:12,代码来源:LessExtendCssErrorFilter.cs

示例15: FilterErrorList

 public void FilterErrorList(IList<ICssError> errors, ICssCheckerContext context)
 {
     for (int i = errors.Count - 1; i > -1; i--)
     {
         ICssError error = errors[i];
         Declaration dec = error.Item.FindType<Declaration>();
         if (dec != null && (dec.Text.Contains("var-") || dec.Text.Contains("var(")))
         {
             errors.RemoveAt(i);
         }
     }
 }
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:12,代码来源:VariableCssErrorFilter.cs


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