internal static bool ValidateColor(StyleInformation.StyleInformationAttribute colorAttribute, ObjectType objectType, string objectName, string propertyName, ErrorContext errorContext)
 {
     if (colorAttribute.ValueType == Microsoft.ReportingServices.ReportIntermediateFormat.ValueType.ThemeReference)
     {
         string stringValue = colorAttribute.Value.StringValue;
         if (string.IsNullOrEmpty(stringValue))
         {
             errorContext.Register(ProcessingErrorCode.rsInvalidColor, Severity.Error, objectType, objectName, propertyName, stringValue);
             return(false);
         }
         return(true);
     }
     return(ValidateColor(colorAttribute.Value, objectType, objectName, propertyName, errorContext));
 }
        internal static Microsoft.ReportingServices.ReportIntermediateFormat.Style ValidateAndCreateStyle(List <StyleInformation.StyleInformationAttribute> attributes, ObjectType objectType, string objectName, bool isDynamicImageSubElement, ErrorContext errorContext, bool checkForMeDotValue, out bool meDotValueReferenced)
        {
            meDotValueReferenced = false;
            Microsoft.ReportingServices.ReportIntermediateFormat.Style style = new Microsoft.ReportingServices.ReportIntermediateFormat.Style(Microsoft.ReportingServices.ReportIntermediateFormat.ConstructionPhase.Publishing);
            Global.Tracer.Assert(attributes != null);
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageSource   = null;
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageValue    = null;
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageMIMEType = null;
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundEmbeddingMode = null;
            for (int i = 0; i < attributes.Count; i++)
            {
                StyleInformation.StyleInformationAttribute styleInformationAttribute = attributes[i];
                if (checkForMeDotValue && styleInformationAttribute.ValueType == Microsoft.ReportingServices.ReportIntermediateFormat.ValueType.Constant && styleInformationAttribute.Value.MeDotValueDetected)
                {
                    meDotValueReferenced = true;
                }
                switch (attributes[i].Name)
                {
                case "BackgroundImageSource":
                    backgroundImageSource = styleInformationAttribute.Value;
                    break;

                case "BackgroundImageValue":
                    backgroundImageValue = styleInformationAttribute.Value;
                    break;

                case "BackgroundImageMIMEType":
                    backgroundImageMIMEType = styleInformationAttribute.Value;
                    break;

                case "BackgroundRepeat":
                    if (ValidateBackgroundRepeat(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "EmbeddingMode":
                    backgroundEmbeddingMode = styleInformationAttribute.Value;
                    break;

                case "Transparency":
                    if (ValidateTransparency(styleInformationAttribute.Value, objectType, objectName, "Transparency", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "TransparentColor":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, "TransparentColor", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderColor":
                case "BorderColorLeft":
                case "BorderColorRight":
                case "BorderColorTop":
                case "BorderColorBottom":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, "BorderColor", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderStyle":
                    if (ValidateBorderStyle(styleInformationAttribute.Value, objectType, objectName, isDynamicImageSubElement, "BorderStyle", isDefaultBorder: true, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderStyleLeft":
                case "BorderStyleRight":
                case "BorderStyleTop":
                case "BorderStyleBottom":
                    if (ValidateBorderStyle(styleInformationAttribute.Value, objectType, objectName, isDynamicImageSubElement, "BorderStyle", isDefaultBorder: false, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderWidth":
                case "BorderWidthLeft":
                case "BorderWidthRight":
                case "BorderWidthTop":
                case "BorderWidthBottom":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.BorderWidthMin, Validator.BorderWidthMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BackgroundGradientEndColor":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BackgroundGradientType":
                    if (ValidateBackgroundGradientType(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "FontStyle":
                    if (ValidateFontStyle(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "FontFamily":
                    style.AddAttribute(styleInformationAttribute);
                    break;

                case "FontSize":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.FontSizeMin, Validator.FontSizeMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "FontWeight":
                    if (ValidateFontWeight(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Format":
                    style.AddAttribute(styleInformationAttribute);
                    break;

                case "TextDecoration":
                    if (ValidateTextDecoration(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "TextAlign":
                    if (ValidateTextAlign(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "VerticalAlign":
                    if (ValidateVerticalAlign(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Color":
                case "BackgroundColor":
                    if (ValidateColor(styleInformationAttribute, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "PaddingLeft":
                case "PaddingRight":
                case "PaddingTop":
                case "PaddingBottom":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.PaddingMin, Validator.PaddingMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "LineHeight":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.LineHeightMin, Validator.LineHeightMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Direction":
                    if (ValidateDirection(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "WritingMode":
                    if (ValidateWritingMode(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Language":
                {
                    if (ValidateSpecificLanguage(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext, out CultureInfo _))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;
                }

                case "UnicodeBiDi":
                    if (ValidateUnicodeBiDi(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Calendar":
                    if (ValidateCalendar(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "CurrencyLanguage":
                    if (ValidateLanguage(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "NumeralLanguage":
                    if (ValidateLanguage(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "NumeralVariant":
                    if (ValidateNumeralVariant(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "ShadowColor":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, "ShadowColor", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "ShadowOffset":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.NormalMin, Validator.NormalMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BackgroundHatchType":
                    if (ValidateBackgroundHatchType(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "TextEffect":
                    if (ValidateTextEffect(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Position":
                    if (ValidatePosition(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

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