예제 #1
0
        /// <summary>
        /// Annotates the entry with atom:published values.
        /// </summary>
        /// <param name="entry">The entry to annotate.</param>
        /// <param name="publishedDate">The value of the atom:published element.</param>
        /// <returns>The feed with the annotation applied.</returns>
        public static EntityInstance AtomPublished(this EntityInstance entry, string publishedDate)
        {
            ExceptionUtilities.CheckArgumentNotNull(entry, "entry");

            entry.AddAnnotation(XmlTreeAnnotation.Atom(TestAtomConstants.AtomPublishedElementName, publishedDate));
            return(entry);
        }
예제 #2
0
        /// <summary>
        /// Annotates the feed with atom:logo values.
        /// </summary>
        /// <param name="feed">The feed to annotate.</param>
        /// <param name="uri">The value of the atom:logo element.</param>
        /// <returns>The feed with the annotation applied.</returns>
        public static EntitySetInstance AtomLogo(this EntitySetInstance feed, string uri)
        {
            ExceptionUtilities.CheckArgumentNotNull(feed, "feed");

            feed.AddAnnotation(XmlTreeAnnotation.Atom(TestAtomConstants.AtomLogoElementName, uri));
            return(feed);
        }
예제 #3
0
        /// <summary>
        /// Creates an annotation representing an atom:category element.
        /// </summary>
        /// <param name="term">The value of the atom:category's term property.</param>
        /// <param name="scheme">The value of the atom:category's scheme property.</param>
        /// <param name="label">The value of the atom:category's label property.</param>
        /// <returns>An annotation representing the atom:category.</returns>
        public static XmlTreeAnnotation AtomCategory(string term, string scheme, string label)
        {
            var categoryAttributes = CreateAtomAttributes(
                new KeyValuePair <string, string>(TestAtomConstants.AtomCategoryTermAttributeName, term),
                new KeyValuePair <string, string>(TestAtomConstants.AtomCategorySchemeAttributeName, scheme),
                new KeyValuePair <string, string>(TestAtomConstants.AtomCategoryLabelAttributeName, label));

            return(XmlTreeAnnotation.Atom(TestAtomConstants.AtomCategoryElementName, null, categoryAttributes));
        }
예제 #4
0
        /// <summary>
        /// Annotates the feed with atom:generator values.
        /// </summary>
        /// <param name="feed">The feed to annotate.</param>
        /// <param name="name">The value of the atom:generator element.</param>
        /// <param name="uri">The value of the atom:generator's URI property.</param>
        /// <param name="version">The value of the atom:generator's version property.</param>
        /// <returns>The feed with the annotation applied.</returns>
        public static EntitySetInstance AtomGenerator(this EntitySetInstance feed, string name, string uri, string version)
        {
            ExceptionUtilities.CheckArgumentNotNull(feed, "feed");

            var generatorAttributes = CreateAtomAttributes(
                new KeyValuePair <string, string>(TestAtomConstants.AtomGeneratorUriAttributeName, uri),
                new KeyValuePair <string, string>(TestAtomConstants.AtomGeneratorVersionAttributeName, version));

            feed.AddAnnotation(XmlTreeAnnotation.Atom(TestAtomConstants.AtomGeneratorElementName, name, generatorAttributes));
            return(feed);
        }
예제 #5
0
        /// <summary>
        /// Annotates the entry with atom:source values.
        /// </summary>
        /// <param name="entry">The entry to annotate.</param>
        /// <param name="sourceFeed">The feed containing metadata to copy.</param>
        /// <returns>The entry with the annotation applied.</returns>
        public static EntityInstance AtomSource(this EntityInstance entry, EntitySetInstance sourceFeed)
        {
            ExceptionUtilities.CheckArgumentNotNull(entry, "entry");
            ExceptionUtilities.CheckArgumentNotNull(sourceFeed, "sourceFeed");

            var sourceAnnotations = sourceFeed.Annotations.OfType <XmlTreeAnnotation>();

            entry.AddAnnotation(
                XmlTreeAnnotation.Atom(
                    TestAtomConstants.AtomSourceElementName,
                    null,
                    sourceAnnotations.Select(a => (XmlTreeAnnotation)a.Clone()).ToArray()));

            return(entry);
        }
예제 #6
0
        /// <summary>
        /// Annotates the payload element with a link annotation and adds the given atom:link attribute values as children on that annotation.
        /// </summary>
        /// <param name="payloadElement">The payload element to annotate.</param>
        /// <param name="href">The value of the atom:link's href property</param>
        /// <param name="rel">The value of the atom:link's rel property</param>
        /// <param name="type">The value of the atom:link's type property</param>
        /// <param name="hrefLang">The optional value of the atom:link's hrefLang property</param>
        /// <param name="title">The optional value of the atom:link's title property</param>
        /// <param name="length">The optional value of the atom:link's length property</param>
        /// <returns>The payload element with the annotation applied.</returns>
        public static T AtomLink <T>(this T payloadElement, string href, string rel, string type, string hrefLang = null, string title = null, string length = null) where T : ODataPayloadElement
        {
            ExceptionUtilities.CheckArgumentNotNull(payloadElement, "payloadElement");

            var linkAttributes = CreateAtomAttributes(
                new KeyValuePair <string, string>(TestAtomConstants.AtomLinkHrefAttributeName, href),
                new KeyValuePair <string, string>(TestAtomConstants.AtomLinkRelationAttributeName, rel),
                new KeyValuePair <string, string>(TestAtomConstants.AtomLinkTypeAttributeName, type),
                new KeyValuePair <string, string>(TestAtomConstants.AtomLinkHrefLangAttributeName, hrefLang),
                new KeyValuePair <string, string>(TestAtomConstants.AtomLinkTitleAttributeName, title),
                new KeyValuePair <string, string>(TestAtomConstants.AtomLinkLengthAttributeName, length));

            payloadElement.AddAnnotation(XmlTreeAnnotation.Atom(TestAtomConstants.AtomLinkElementName, null, linkAttributes));
            return(payloadElement);
        }