示例#1
0
        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (!WESettings.Instance.Css.ValidateVendorSpecifics)
            {
                return(ItemCheckResult.Continue);
            }

            Declaration dec = (Declaration)item;

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

            ICssSchemaInstance schema = CssEditorChecker.GetSchemaForItem(context, item);
            var missingEntries        = dec.GetMissingVendorSpecifics(schema);

            if (missingEntries.ToArray().Length > 0)
            {
                var       missingPrefixes = missingEntries.Select(e => e.Substring(0, e.IndexOf('-', 1) + 1));
                string    error           = string.Format(CultureInfo.InvariantCulture, Resources.BestPracticeAddMissingVendorSpecific, dec.PropertyName.Text, string.Join(", ", missingPrefixes));
                ICssError tag             = new SimpleErrorTag(dec.PropertyName, error);
                context.AddError(tag);
                return(ItemCheckResult.CancelCurrentItem);
            }

            return(ItemCheckResult.Continue);
        }