Beispiel #1
0
 /// <summary>Resets object state to default, as if newly created.
 /// </summary>
 protected virtual void Reset()
 {
     this.query           = this.author = this.oauthRequestorId = String.Empty;
     this.categories      = null;
     this.datetimeMax     = this.datetimeMin = Utilities.EmptyDate;
     this.MinPublication  = this.MaxPublication = Utilities.EmptyDate;
     this.ifModifiedSince = DateTime.MinValue;
     this.startIndex      = this.numToRetrieve = 0;
     this.altFormat       = AlternativeFormat.Atom;
 }
Beispiel #2
0
 /// <summary>Resets object state to default, as if newly created.
 /// </summary>
 protected virtual void Reset()
 {
     _query           = _author = _oauthRequestorId = String.Empty;
     _categories      = null;
     _datetimeMax     = _datetimeMin = Utilities.EmptyDate;
     MinPublication   = MaxPublication = Utilities.EmptyDate;
     _ifModifiedSince = DateTime.MinValue;
     _startIndex      = _numToRetrieve = 0;
     _altFormat       = AlternativeFormat.Atom;
 }
        public void FeedFormatTest()
        {
            FeedQuery         target   = new FeedQuery(); // TODO: Initialize to an appropriate value
            AlternativeFormat expected = AlternativeFormat.Rss;
            AlternativeFormat actual;

            target.FeedFormat = expected;
            actual            = target.FeedFormat;
            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        /// <summary>Converts an AlternativeFormat to a string for use in
        /// the query string.</summary>
        /// <param name="format">the format that we want to be converted to string </param>
        /// <returns>string version of the format</returns>
        static protected string FormatToString(AlternativeFormat format)
        {
            switch (format)
            {
            case AlternativeFormat.Atom:
                return("atom");

            case AlternativeFormat.Rss:
                return("rss");

            case AlternativeFormat.OpenSearchRss:
                return("osrss");
            }
            return(null);
        }
        /////////////////////////////////////////////////////////////////////////////

        #endregion



        //////////////////////////////////////////////////////////////////////
        /// <summary>given a stream, parses it to construct the Feed object out of it</summary>
        /// <param name="stream"> a stream representing hopefully valid XML</param>
        /// <param name="format"> indicates if the stream is Atom or Rss</param>
        //////////////////////////////////////////////////////////////////////
        public void Parse(Stream stream, AlternativeFormat format)
        {
            Tracing.TraceCall("parsing stream -> Start:" + format.ToString());
            BaseFeedParser feedParser = null;

            // make sure we reset our collections
            this.Authors.Clear();
            this.Contributors.Clear();
            this.Links.Clear();
            this.Categories.Clear();

            feedParser = new AtomFeedParser(this);

            // create a new delegate for the parser
            feedParser.NewAtomEntry        += new FeedParserEventHandler(this.OnParsedNewEntry);
            feedParser.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);
            feedParser.Parse(stream, this);

            Tracing.TraceInfo("Parsing stream -> Done");
            // done parsing
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Resets object state to default, as if newly created.
        /// </summary> 
        //////////////////////////////////////////////////////////////////////
        protected virtual void Reset()
        {
            this.query = this.author = this.oauthRequestorId = String.Empty; 
            this.categories = null; 
            this.datetimeMax = this.datetimeMin = Utilities.EmptyDate; 
            this.MinPublication = this.MaxPublication = Utilities.EmptyDate; 
            this.ifModifiedSince = DateTime.MinValue; 
            this.startIndex = this.numToRetrieve = 0; 
            this.altFormat = AlternativeFormat.Atom;
        }
 //////////////////////////////////////////////////////////////////////
 /// <summary>Converts an AlternativeFormat to a string for use in
 /// the query string.</summary> 
 /// <param name="format">the format that we want to be converted to string </param>
 /// <returns>string version of the format</returns>
 //////////////////////////////////////////////////////////////////////
 static protected string FormatToString(AlternativeFormat format)
 {
     switch (format)
     {
         case AlternativeFormat.Atom:
             return "atom";
         case AlternativeFormat.Rss:
             return "rss";
         case AlternativeFormat.OpenSearchRss:
             return "osrss";
     }
     return null;
 }
Beispiel #8
0
        /////////////////////////////////////////////////////////////////////////////

#endregion




        //////////////////////////////////////////////////////////////////////
        /// <summary>given a stream, parses it to construct the Feed object out of it</summary> 
        /// <param name="stream"> a stream representing hopefully valid XML</param>
        /// <param name="format"> indicates if the stream is Atom or Rss</param>
        //////////////////////////////////////////////////////////////////////
        public void Parse(Stream stream, AlternativeFormat format)
        {
            Tracing.TraceCall("parsing stream -> Start:" + format.ToString());
            BaseFeedParser feedParser= null; 

            feedParser = new AtomFeedParser();

            // create a new delegate for the parser
            feedParser.NewAtomEntry += new FeedParserEventHandler(this.OnParsedNewEntry); 
            feedParser.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);
            feedParser.Parse(stream, this);

            Tracing.TraceInfo("Parsing stream -> Done"); 
            // done parsing
        }
Beispiel #9
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Resets object state to default, as if newly created.
        /// </summary> 
        //////////////////////////////////////////////////////////////////////
        protected virtual void Reset()
        {
            this.query = this.author = String.Empty; 
            this.categories = null; 
            this.datetimeMax = this.datetimeMin = Utilities.EmptyDate; 
            this.MinPublication = this.MaxPublication = Utilities.EmptyDate; 
            this.startIndex = this.numToRetrieve = 0; 
            this.altFormat = AlternativeFormat.Atom;
        }