Exemplo n.º 1
0
        /// <summary>
        /// Gets the text align attribute value for a specified align option
        /// </summary>
        /// <param name="align">The align option</param>
        /// <returns>The text align attribute value</returns>
        public static string GetTextAlignAttributeValue(TextAlignOption align)
        {
            // Validate the arguments
            // align does not require validation


            string formattedValue = null;

            switch (align)
            {
            case TextAlignOption.Left:
                formattedValue = "left";
                break;

            case TextAlignOption.Center:
                formattedValue = "center";
                break;

            case TextAlignOption.Right:
                formattedValue = "right";
                break;

            default:
                throw new ArgumentException($"Argument {nameof(align)} contains an unsupported value.", nameof(align));
            }

            return(formattedValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a legalNotice element with the specified notice text to the parent element
        /// </summary>
        /// <param name="parent">Reference to the parent element</param>
        /// <param name="root">Reference to the root XML document</param>
        /// <param name="notice">The notice text</param>
        /// <param name="align">The text alignment</param>
        internal static void AddLegalNoticeElement(XmlElement parent, XmlDocument root, string notice, TextAlignOption align)
        {
            // Validate the arguments
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            // notice does not require validation
            // align does not require validation


            // Add the legalNotice element with the specified notice
            const string nodeName = "legalNotice";
            XmlElement   node     = AddElement(parent, root, nodeName);

            node.InnerText = notice;

            // Add the align attribute
            if (align != TextAlignOption.Left)
            {
                const string alignAttributeName = "align";
                string       alignValue         = GetTextAlignAttributeValue(align);
                AddAttribute(node, root, alignAttributeName, alignValue, false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a legalNotices element with the specified legal notices to the parent element
        /// </summary>
        /// <param name="parent">Reference to the parent element</param>
        /// <param name="root">Reference to the root XML document</param>
        /// <param name="legalNotices">The legal notices</param>
        /// <param name="align">The text alignment</param>
        internal static void AddLegalNoticesElement(XmlElement parent, XmlDocument root, string[] legalNotices, TextAlignOption align)
        {
            // Validate the arguments
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            // legalNotices does not require validation
            // align does not require validation


            // If there are any legal notices to add
            if (legalNotices != null)
            {
                if (legalNotices.Length > 0)
                {
                    // Add the legalNotices element
                    const string nodeName = "legalNotices";
                    XmlElement   node     = AddElement(parent, root, nodeName);

                    // Add the legal notices
                    foreach (string notice in legalNotices)
                    {
                        AddLegalNoticeElement(node, root, notice, align);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a caption element with the specified caption text to the parent element
        /// </summary>
        /// <param name="parent">Reference to the parent element</param>
        /// <param name="root">Reference to the root XML document</param>
        /// <param name="caption">The caption text</param>
        /// <param name="align">The text alignment</param>
        public static void AddCaptionElement(XmlElement parent, XmlDocument root, string caption, TextAlignOption align)
        {
            // Validate the arguments
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            // caption does not require validation
            // align does not require validation


            // Add the caption element with the specified caption
            const string nodeName = "caption";
            XmlElement   node     = AddElement(parent, root, nodeName);

            node.InnerText = caption;

            // Add the align attribute
            if (align != TextAlignOption.Left)
            {
                const string alignAttributeName = "align";
                string       alignValue         = GetTextAlignAttributeValue(align);
                AddAttribute(node, root, alignAttributeName, alignValue, false);
            }
        }