/// <summary>
        /// Serialize a request as root node of an XML stream.
        /// </summary>
        /// <param name="xmlWriter">XML stream.</param>
        /// <param name="request">Request.</param>
        /// <returns>XML stream with request as root node.</returns>
        public static XmlWriter SerializeRoot(XmlWriter xmlWriter, Request request)
        {
            XmlWriter    lXMLWriter    = null;
            MemoryStream lMemoryStream = XMLRequestSerializer.SerializeRoot(request);

            if (lMemoryStream != null)
            {
                lXMLWriter = XmlWriter.Create(lMemoryStream);
            }
            return(lXMLWriter);
        }
        /// <summary>
        /// Serialize a request as a StringBuilder.
        /// </summary>
        /// <param name="stringBuilder">StringBuilder.</param>
        /// <param name="request">Request.</param>
        /// <returns>StringBuilder.</returns>
        public static StringBuilder SerializeRoot(StringBuilder stringBuilder, Request request)
        {
            if (stringBuilder == null)
            {
                stringBuilder = new StringBuilder();
            }

            MemoryStream lMemoryStream = XMLRequestSerializer.SerializeRoot(request);

            if (lMemoryStream != null)
            {
                using (lMemoryStream)
                {
                    lMemoryStream.Position = 0;
                    StreamReader lReader = new StreamReader(lMemoryStream);
                    using (lReader)
                    {
                        stringBuilder.Append(lReader.ReadToEnd());
                    }
                }
            }
            return(stringBuilder);
        }