/// <summary>
        /// Writes the condition to the specified XML writer using the specified XML element name.
        /// </summary>
        /// <param name="elementName">The XML element name that will contain the serialized condition.</param>
        /// <param name="condition">The condition to serialize.</param>
        /// <param name="xmlWriter">The XML writer used to write the image to.</param>
        public static void WriteConditionXml(string elementName, Condition condition, XmlWriter xmlWriter)
        {
            if (string.IsNullOrEmpty(elementName))
            {
                throw new ArgumentNullException("elementName");
            }

            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }

            if (xmlWriter == null)
            {
                throw new ArgumentNullException("xmlWriter");
            }

            xmlWriter.WriteStartElement(elementName);
            xmlWriter.WriteElementString("operator", condition.Operator.ToString());
            xmlWriter.WriteElementString("columnName", condition.ColumnName ?? string.Empty);
            condition.ColumnType.ToXml(xmlWriter);

            xmlWriter.WriteStartElement("arguments");
            if (condition.Arguments != null)
            {
                foreach (TypedValue arg in condition.Arguments)
                {
                    TypedValueHelper.WriteTypedValueXml("argument", arg, xmlWriter);
                }
            }
            xmlWriter.WriteEndElement(); // arguments

            xmlWriter.WriteEndElement(); //elementName
        }
        /// <summary>
        /// Writes the bar formatting rule to the specified XML writer.
        /// </summary>
        /// <param name="barFormattingRule">The bar formatting rule to serialize.</param>
        /// <param name="xmlWriter">The XML writer used to write the image to.</param>
        private static void WriteBarFormattingRuleXml(BarFormattingRule barFormattingRule, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("barFormattingRule");

            ColorInfoHelper.WriteColorInfoXml("color", barFormattingRule.Color, xmlWriter);
            TypedValueHelper.WriteTypedValueXml("minimum", barFormattingRule.Minimum, xmlWriter);
            TypedValueHelper.WriteTypedValueXml("maximum", barFormattingRule.Maximum, xmlWriter);

            xmlWriter.WriteEndElement(); // barFormattingRule
        }