/// <summary>
        /// Writes the 'atom:category' element with the specified attributes.
        /// </summary>
        /// <param name="atomPrefix">The prefix to use for the 'category' element.</param>
        /// <param name="term">The value for the 'term' attribute (required).</param>
        /// <param name="scheme">The value for the 'scheme' attribute (optional).</param>
        /// <param name="label">The value for the 'label' attribute (optional).</param>
        internal void WriteCategory(string atomPrefix, string term, string scheme, string label)
        {
            this.XmlWriter.WriteStartElement(
                atomPrefix,
                AtomConstants.AtomCategoryElementName,
                AtomConstants.AtomNamespace);

            if (term == null)
            {
                throw new ODataException(ODataErrorStrings.ODataAtomWriterMetadataUtils_CategoryMustSpecifyTerm);
            }

            this.XmlWriter.WriteAttributeString(
                AtomConstants.AtomCategoryTermAttributeName,
                ODataAtomWriterUtils.PrefixTypeName(term));

            if (scheme != null)
            {
                this.XmlWriter.WriteAttributeString(AtomConstants.AtomCategorySchemeAttributeName, scheme);
            }

            if (label != null)
            {
                this.XmlWriter.WriteAttributeString(AtomConstants.AtomCategoryLabelAttributeName, label);
            }

            this.XmlWriter.WriteEndElement();
        }
Beispiel #2
0
 /// <summary>
 /// Writes the m:type attribute for a property given the name of the type.
 /// </summary>
 /// <param name="typeName">The type name to write.</param>
 private void WritePropertyTypeAttribute(string typeName)
 {
     // m:type attribute
     this.XmlWriter.WriteAttributeString(
         AtomConstants.ODataMetadataNamespacePrefix,
         AtomConstants.AtomTypeAttributeName,
         AtomConstants.ODataMetadataNamespace,
         ODataAtomWriterUtils.PrefixTypeName(WriterUtils.RemoveEdmPrefixFromTypeName(typeName)));
 }