예제 #1
0
        /// <summary>
        /// Saves the current <see cref="XmlRpcScalarValue"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(writer, "writer");

            //------------------------------------------------------------
            //	Write XML representation of the current instance
            //------------------------------------------------------------
            writer.WriteStartElement("value");

            if (this.ValueType != XmlRpcScalarValueType.None)
            {
                writer.WriteStartElement(XmlRpcClient.ScalarTypeAsString(this.ValueType));
                writer.WriteString(XmlRpcScalarValue.ValueAsString(this.ValueType, this.Value));
                writer.WriteEndElement();
            }
            else
            {
                writer.WriteString(this.Value != null ? this.Value.ToString() : String.Empty);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="XmlRpcScalarValue"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        public void WriteTo(XmlWriter writer)
        {
            Guard.ArgumentNotNull(writer, "writer");

            writer.WriteStartElement("value");

            if (this.ValueType != XmlRpcScalarValueType.None)
            {
                writer.WriteStartElement(XmlRpcClient.ScalarTypeAsString(this.ValueType));
                writer.WriteString(XmlRpcScalarValue.ValueAsString(this.ValueType, this.Value));
                writer.WriteEndElement();
            }
            else
            {
                writer.WriteString(this.Value != null ? this.Value.ToString() : String.Empty);
            }

            writer.WriteEndElement();
        }