예제 #1
0
        /// <summary>
        /// Writes the XML representation of the AssociatedTypeInfo into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the associated type info.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the AssociatedTypeInfo should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            if (string.IsNullOrEmpty(nodeName))
            {
                throw new ArgumentException(
                          Resources.WriteXmlEmptyNodeName,
                          nameof(nodeName));
            }

            if (writer == null)
            {
                throw new ArgumentNullException(
                          nameof(writer),
                          Resources.WriteXmlNullWriter);
            }

            writer.WriteStartElement(nodeName);

            if (_thingTypeVersionId.Equals(Guid.Empty))
            {
                throw new InvalidOperationException(Resources.AssociatedThingTypeVersionIdNullorEmpty);
            }

            XmlWriterHelper.WriteOptGuid(writer, "thing-type-version-id", _thingTypeVersionId);
            XmlWriterHelper.WriteOptString(writer, "thing-type-value-xpath", _thingTypeValueXPath);
            XmlWriterHelper.WriteOptString(writer, "thing-type-display-xpath", _thingTypeDisplayXPath);
            writer.WriteEndElement();
        }