/// <summary>
        /// Writes the icon formatting rule to the specified XML writer.
        /// </summary>
        /// <param name="iconFormattingRule">The icon formatting rule to serialize.</param>
        /// <param name="xmlWriter">The XML writer used to write the image to.</param>
        private static void WriteIconFormattingRuleXml(IconFormattingRule iconFormattingRule, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("iconFormattingRule");
            xmlWriter.WriteStartElement("rules");
            foreach (IconRule rule in iconFormattingRule.Rules)
            {
                xmlWriter.WriteStartElement("rule");

                ColorInfoHelper.WriteColorInfoXml("color", rule.Color, xmlWriter);
                xmlWriter.WriteElementString("icon", rule.Icon.ToString());
                ConditionHelper.WriteConditionXml("condition", rule.Condition, xmlWriter);
                // Write out the Icon ID
                if (rule.IconId.HasValue)
                {
                    xmlWriter.WriteStartElement("iconId");
                    xmlWriter.WriteAttributeString("entityRef", "true");
                    xmlWriter.WriteString(rule.IconId.Value.ToString(CultureInfo.InvariantCulture));
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement(); // rule
            }
            xmlWriter.WriteEndElement();     // rules
            xmlWriter.WriteEndElement();     // iconFormattingRule
        }
        public void WriteColorInfoXmlEmptyElementNameTest( )
        {
            var       writerText = new StringBuilder( );
            XmlWriter writer     = XmlWriter.Create(writerText, new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            });

            ColorInfoHelper.WriteColorInfoXml(string.Empty, new ColorInfo( ), writer);
        }
        public void WriteColorInfoXmlNullColorInfoTest( )
        {
            var       writerText = new StringBuilder( );
            XmlWriter writer     = XmlWriter.Create(writerText, new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            });

            ColorInfoHelper.WriteColorInfoXml("color", null, writer);
        }
        /// <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
        }
        /// <summary>
        /// Writes the color formatting rule to the specified XML writer.
        /// </summary>
        /// <param name="colorFormattingRule">The color formatting rule to serialize.</param>
        /// <param name="xmlWriter">The XML writer used to write the image to.</param>
        private static void WriteColorFormattingRuleXml(ColorFormattingRule colorFormattingRule, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("colorFormattingRule");
            xmlWriter.WriteStartElement("rules");
            foreach (ColorRule rule in colorFormattingRule.Rules)
            {
                xmlWriter.WriteStartElement("rule");

                ColorInfoHelper.WriteColorInfoXml("backgroundColor", rule.BackgroundColor, xmlWriter);
                ColorInfoHelper.WriteColorInfoXml("foregroundColor", rule.ForegroundColor, xmlWriter);
                ConditionHelper.WriteConditionXml("condition", rule.Condition, xmlWriter);

                xmlWriter.WriteEndElement(); // rule
            }
            xmlWriter.WriteEndElement();     // rules
            xmlWriter.WriteEndElement();     // colorFormattingRule
        }
 public void WriteColorInfoXmlNullXmlWriterTest( )
 {
     ColorInfoHelper.WriteColorInfoXml("color", new ColorInfo( ), null);
 }