Esempio n. 1
0
 private static void ValidateBackgroundImage(ExpressionInfo backgroundImageSource, ExpressionInfo backgroundImageValue, ExpressionInfo backgroundImageMIMEType, Style style, ObjectType objectType, string objectName, ErrorContext errorContext)
 {
     if (backgroundImageSource != null)
     {
         bool flag = true;
         Global.Tracer.Assert(ExpressionInfo.Types.Constant == backgroundImageSource.Type);
         Image.SourceType intValue = (Image.SourceType)backgroundImageSource.IntValue;
         Global.Tracer.Assert(null != backgroundImageValue);
         if (Image.SourceType.Database == intValue && ExpressionInfo.Types.Constant == backgroundImageValue.Type)
         {
             errorContext.Register(ProcessingErrorCode.rsBinaryConstant, Severity.Error, objectType, objectName, "BackgroundImageValue");
             flag = false;
         }
         if (Image.SourceType.Database == intValue && !PublishingValidator.ValidateMimeType(backgroundImageMIMEType, objectType, objectName, "BackgroundImageMIMEType", errorContext))
         {
             flag = false;
         }
         if (flag)
         {
             style.AddAttribute("BackgroundImageSource", backgroundImageSource);
             style.AddAttribute("BackgroundImageValue", backgroundImageValue);
             if (Image.SourceType.Database == intValue)
             {
                 style.AddAttribute("BackgroundImageMIMEType", backgroundImageMIMEType);
             }
         }
     }
 }
Esempio n. 2
0
        public static Style ValidateAndCreateStyle(StringList names, ExpressionInfoList values, ObjectType objectType, string objectName, ErrorContext errorContext)
        {
            Style style = new Style(ConstructionPhase.Publishing);

            Global.Tracer.Assert(null != names);
            Global.Tracer.Assert(null != values);
            Global.Tracer.Assert(names.Count == values.Count);
            ExpressionInfo backgroundImageSource   = null;
            ExpressionInfo backgroundImageValue    = null;
            ExpressionInfo backgroundImageMIMEType = null;

            for (int i = 0; i < names.Count; i++)
            {
                switch (names[i])
                {
                case "BackgroundImageSource":
                    backgroundImageSource = values[i];
                    break;

                case "BackgroundImageValue":
                    backgroundImageValue = values[i];
                    break;

                case "BackgroundImageMIMEType":
                    backgroundImageMIMEType = values[i];
                    break;

                case "BackgroundRepeat":
                    if (PublishingValidator.ValidateBackgroundRepeat(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderColor":
                case "BorderColorLeft":
                case "BorderColorRight":
                case "BorderColorTop":
                case "BorderColorBottom":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, "BorderColor", errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderStyle":
                case "BorderStyleLeft":
                case "BorderStyleRight":
                case "BorderStyleTop":
                case "BorderStyleBottom":
                    if (PublishingValidator.ValidateBorderStyle(values[i], objectType, objectName, "BorderStyle", errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderWidth":
                case "BorderWidthLeft":
                case "BorderWidthRight":
                case "BorderWidthTop":
                case "BorderWidthBottom":
                    if (PublishingValidator.ValidateSize(values[i], Validator.BorderWidthMin, Validator.BorderWidthMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BackgroundColor":
                case "BackgroundGradientEndColor":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BackgroundGradientType":
                    if (PublishingValidator.ValidateBackgroundGradientType(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontStyle":
                    if (PublishingValidator.ValidateFontStyle(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontFamily":
                    style.AddAttribute(names[i], values[i]);
                    break;

                case "FontSize":
                    if (PublishingValidator.ValidateSize(values[i], Validator.FontSizeMin, Validator.FontSizeMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontWeight":
                    if (PublishingValidator.ValidateFontWeight(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Format":
                    style.AddAttribute(names[i], values[i]);
                    break;

                case "TextDecoration":
                    if (PublishingValidator.ValidateTextDecoration(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "TextAlign":
                    if (PublishingValidator.ValidateTextAlign(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "VerticalAlign":
                    if (PublishingValidator.ValidateVerticalAlign(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Color":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "PaddingLeft":
                case "PaddingRight":
                case "PaddingTop":
                case "PaddingBottom":
                    if (PublishingValidator.ValidateSize(values[i], Validator.PaddingMin, Validator.PaddingMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "LineHeight":
                    if (PublishingValidator.ValidateSize(values[i], Validator.LineHeightMin, Validator.LineHeightMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Direction":
                    if (PublishingValidator.ValidateDirection(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "WritingMode":
                    if (PublishingValidator.ValidateWritingMode(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Language":
                {
                    CultureInfo cultureInfo = default(CultureInfo);
                    if (PublishingValidator.ValidateSpecificLanguage(values[i], objectType, objectName, names[i], errorContext, out cultureInfo))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;
                }

                case "UnicodeBiDi":
                    if (PublishingValidator.ValidateUnicodeBiDi(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Calendar":
                    if (PublishingValidator.ValidateCalendar(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "NumeralLanguage":
                    if (PublishingValidator.ValidateLanguage(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "NumeralVariant":
                    if (PublishingValidator.ValidateNumeralVariant(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                default:
                    Global.Tracer.Assert(false);
                    break;
                }
            }
            PublishingValidator.ValidateBackgroundImage(backgroundImageSource, backgroundImageValue, backgroundImageMIMEType, style, objectType, objectName, errorContext);
            if (0 < style.StyleAttributes.Count)
            {
                return(style);
            }
            return(null);
        }