Example #1
0
        /// <summary>
        /// Initializes the current <see cref="AtomFeed"/> instance from a
        /// given XML element.
        /// </summary>
        /// <param name="element">The XML element.</param>
        internal override void Init(XmlElement element)
        {
            string name = element.Name;

            if (name.Equals("entry"))
            {
                AtomEntry entry = AtomEntry.Parse(element);
                this.Entries.Add(entry);
            }
            else if (name.Equals("s:messages"))
            {
                // Ignore
            }
            else if (name.Equals("opensearch:totalResults"))
            {
                this.TotalResults = element.InnerText;
            }
            else if (name.Equals("opensearch:itemsPerPage"))
            {
                this.ItemsPerPage = element.InnerText;
            }
            else if (name.Equals("opensearch:startIndex"))
            {
                this.StartIndex = element.InnerText;
            }
            else
            {
                base.Init(element);
            }
        }
Example #2
0
        /// <summary>
        /// Creates a new <see cref="AtomEntry"/> instance based on a given
        /// stream.
        /// </summary>
        /// <param name="input">The I/O stream.</param>
        /// <returns>An Atom entry.</returns>
        /// <remarks>
        /// A few endpoints, such as search/jobs/{sid}
        /// return an Atom entry element as the root of the response.
        /// </remarks>
        public static AtomEntry Parse(Stream input)
        {
            XmlElement root  = Xml.Parse(input).DocumentElement;
            string     rname = root.Name;
            string     xmlns = root.GetAttribute("xmlns");

            if (!rname.Equals("entry") &&
                !xmlns.Equals("http://www.w3.org/2005/Atom"))
            {
                throw new Exception("Unrecognized XML format");
            }
            return(AtomEntry.Parse(root));
        }
Example #3
0
        // Job "entities" don't return an AtomFeed, only an AtomEntry.

        /// <summary>
        /// Refreshes this job.
        /// </summary>
        /// <returns>The extended resource, the <see cref="Job"/>.</returns>
        public override Resource Refresh()
        {
            this.Update();
            ResponseMessage response = Service.Get(Path);

            if (response.Status == 204)
            {
                this.isReady = false;
                return(null);
            }

            this.isReady = true;
            AtomEntry entry = AtomEntry.Parse(response.Content);

            this.Load(entry);
            return(this);
        }