/// <summary>constructor for the feedParser events</summary> 
 /// <param name="feed">the feed to use </param>
 /// <param name="entry">the feedentry to use </param> 
 public FeedParserEventArgs(AtomFeed feed, AtomEntry entry) {
     this.feedEntry = entry;
     this.feed = feed;
     if (feed == null && entry == null) {
         this.done = true;
     }
 }
Esempio n. 2
0
 private AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomEntry entry, AtomFeed feed,
     SendOrPostCallback callback, object userData, bool parseFeed)
     : base(uriToUse, null, userData, callback, parseFeed) {
     this.DataHandler = handler;
     this.entry = entry;
     this.Feed = feed;
 }
Esempio n. 3
0
        /// <summary>
        /// constructor. takes the async data blob
        /// </summary>
        /// <param name="data">async data to constructor</param>
        internal AsyncOperationCompletedEventArgs(AsyncData data)
            : base(data.Exception, false, data.UserData) {
            feedObject = data.Feed;
            stream = data.DataStream;

            IAsyncEntryData entryData = data as IAsyncEntryData;
            if (entryData != null) {
                entryObject = entryData.Entry;
            }
        }
        /// <summary>starts the parsing process</summary> 
        /// <param name="streamInput">input stream to parse </param>
        /// <param name="feed">the basefeed object that should be set</param> 
        public override void Parse(Stream streamInput, AtomFeed feed) {
            Tracing.TraceCall("feedparser starts parsing");
            try {
                XmlReader reader = new XmlTextReader(streamInput, this.nameTable.Nametable);

                MoveToStartElement(reader);
                ParseFeed(reader, feed);
            } catch (Exception e) {
                throw new ClientFeedException("Parsing failed", e);
            }
        }
Esempio n. 5
0
        public void TestGZipQuery()
        {
            IGDataRequest request = this.calendarService.RequestFactory.CreateRequest(GDataRequestType.Query, new Uri(calendarUri));
            Assert.IsTrue(request.UseGZip, "IGDataRequest.UseGZip property should be true.");

            request.Credentials = new GDataCredentials(this.userName, this.passWord);
            request.Execute();
            Assert.IsTrue(request.UseGZip, "IGDataRequest.UseGZip is not true, the response was NOT in GZip format.");

            Stream responseStream = request.GetResponseStream();
            Assert.IsTrue(responseStream != null, "Response stream should not be null.");

            AtomFeed feed = new AtomFeed(new Uri(calendarUri), this.calendarService);
            feed.Parse(request.GetResponseStream(), AlternativeFormat.Atom);
            Assert.IsTrue(feed.Self != null, "AtomFeed object is not right.");
        }
       /// <summary>
       /// constructor. takes the async data blog
       /// </summary>
       /// <param name="data">async data to constructor</param>
       internal AsyncOperationCompletedEventArgs(AsyncData data) : base(data.Exception, false, data.UserData)
       {
           AsyncQueryData qData = data as AsyncQueryData;
           AsyncSendData sData = data as AsyncSendData;

           this.uri = data.UriToUse;

           if (qData != null)
           {
               this.feedObject = qData.Feed;
               this.stream = qData.DataStream;
           }
           if (sData != null)
           {
               this.entryObject = sData.Entry;
           }
       }
        private static List<Webinar> ParseAtomFeed(AtomFeed atomFeed)
        {
            IEnumerable<AtomEntry> atomEntryCollection = atomFeed.Entries;
            var webinars = new List<Webinar>();

            foreach (var item in atomEntryCollection)
            {
                var entry = (YouTubeEntry) item;
                var webinar = new Webinar
                {
                    Id = entry.VideoId,
                    Title = entry.Title.Text,
                    Summary = entry.Summary.Text,
                    Published = entry.Published
                };

                webinars.Add(webinar);
            }

            return webinars;
        }
Esempio n. 8
0
        /// <summary>public AtomSource(AtomFeed feed)</summary>
        public AtomSource(AtomFeed feed)
            : this()
        {
            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null)
            {
                throw new ArgumentNullException("feed");
            }

            // now copy them
            this.authors      = feed.Authors;
            this.contributors = feed.Contributors;
            this.categories   = feed.Categories;
            this.Generator    = feed.Generator;
            this.Icon         = feed.Icon;
            this.Logo         = feed.Logo;
            this.Id           = feed.Id;
            this.links        = feed.Links;
            this.Rights       = feed.Rights;
            this.Subtitle     = feed.Subtitle;
            this.Title        = feed.Title;
            this.Updated      = feed.Updated;
        }
Esempio n. 9
0
        /// <summary>creates a new feed instance to be returned by
        /// Batch(), Query() and other operations
        ///
        /// Subclasses can supply their own feed implementation by
        /// overriding this method.
        /// </summary>
        protected virtual AtomFeed CreateFeed(Uri uriToUse)
        {
            ServiceEventArgs args = null;
            AtomFeed         feed = null;

            if (this.NewFeed != null)
            {
                args = new ServiceEventArgs(uriToUse, this);
                this.NewFeed(this, args);
            }

            if (args != null)
            {
                feed = args.Feed;
            }

            if (feed == null)
            {
                feed = new AtomFeed(uriToUse, this);
            }

            return(feed);
        }
Esempio n. 10
0
        /// <summary>public WebResponse Insert(Uri insertUri, Stream entryStream, ICredentials credentials)</summary>
        /// <param name="feed">the feed this entry should be inserted into</param>
        /// <param name="entry">the entry to be inserted</param>
        /// <returns> the inserted entry</returns>
        AtomEntry IService.Insert(AtomFeed feed, AtomEntry entry)
        {
            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null)
            {
                throw new ArgumentNullException("feed");
            }

            Tracing.Assert(entry != null, "entry should not be null");
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            if (feed.ReadOnly)
            {
                throw new GDataRequestException("Can not update a read-only feed");
            }

            Tracing.TraceMsg("Post URI is: " + feed.Post);
            Uri target = new Uri(feed.Post);

            return(Insert(target, entry));
        }
Esempio n. 11
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>overloaded to make eventfiring easier</summary>
        /// <param name="feed"> the new feed to fire</param>
        //////////////////////////////////////////////////////////////////////
        protected void OnNewAtomEntry(AtomFeed feed)
        {
            FeedParserEventArgs args = new FeedParserEventArgs(feed, null);

            this.OnNewAtomEntry(args);
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>starts the parsing process</summary>
        /// <param name="streamInput">input stream to parse </param>
        /// <param name="feed">the feed object to construct</param>
        //////////////////////////////////////////////////////////////////////
        public override void Parse(Stream streamInput, AtomFeed feed)
        {
        }
Esempio n. 13
0
 public static void ProcessSubmissions(AtomFeed feed)
 {
     int i = 0;
     Submission submission = new Submission();
     foreach(ListEntry entry in feed.Entries)
     {
         if (i>0)
         {
             Submissions.Add(submission);
             i = 0;
             submission = new Submission();
         }
         foreach(ListEntry.Custom listrow in entry.Elements)
         {
             switch (i)
             {
                 case 0: submission.CSF = listrow.Value;
                     break;
                 case 1: submission.PlannedDate = listrow.Value;
                     break;
                 case 2: submission.SubmittedDate = listrow.Value;
                     break;
                 case 3: submission.SubmissionType = listrow.Value;
                     break;
                 case 4: submission.Milestone = listrow.Value;
                     break;
                 case 5: submission.Title = listrow.Value;
                     break;
                 case 6: submission.Number = listrow.Value;
                     break;
                 case 7: submission.Revision = listrow.Value;
                     break;
                 case 9: submission.UpdatedDate = listrow.Value;
                     break;
             }
             i++;
         }
     }
 }
Esempio n. 14
0
		/////////////////////////////////////////////////////////////////////////////

		//////////////////////////////////////////////////////////////////////
		/// <summary>default constructor so that FxCop does not complain</summary> 
		//////////////////////////////////////////////////////////////////////
		public GDataBatchRequestException(AtomFeed batchResult)
		{
			this.batchResult = batchResult;
		}
Esempio n. 15
0
 public void XmlNameTest()
 {
     AtomFeed target = new AtomFeed(new Uri("http://www.test.com/"), null); 
     Assert.AreEqual(AtomParserNameTable.XmlFeedElement, target.XmlName);
 }
Esempio n. 16
0
 public AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomFeed feed, SendOrPostCallback callback, object userData)
     : this(handler, uriToUse, null, feed, callback, userData, false) {
 }
Esempio n. 17
0
 /// <summary>
 /// takes a given feed, and does a batch post of that feed
 /// against the batchUri parameter. If that one is NULL 
 /// it will try to use the batch link URI in the feed
 /// </summary>
 /// <param name="feed">the feed to post</param>
 /// <param name="batchUri">the URI to user</param>
 /// <param name="userData">the userdata identifying this request</param>
 /// <returns></returns>
 public void BatchAsync(AtomFeed feed, Uri batchUri, Object userData) {
     AsyncSendData data = new AsyncSendData(this, batchUri, feed, this.ProgressReportDelegate, userData);
     WorkerSendEventHandler workerDelegate = new WorkerSendEventHandler(AsyncBatchWorker);
     this.AsyncStarter(data, workerDelegate, userData);
 }
        /// <summary>reads in the feed properties, updates the feed object, then starts
        /// working on the entries...</summary> 
        /// <param name="reader"> xmlReader positioned at the Feed element</param>
        /// <param name="feed">the basefeed object that should be set</param>
        /// <returns> notifies user using event mechanism</returns>
        protected void ParseFeed(XmlReader reader, AtomFeed feed) {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null) {
                throw new ArgumentNullException("reader");
            }

            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null) {
                throw new ArgumentNullException("feed");
            }

            Tracing.TraceCall("entering AtomFeed Parser");
            object localname = reader.LocalName;
            Tracing.TraceInfo("localname is: " + reader.LocalName);
            if (localname.Equals(this.nameTable.Feed)) {
                Tracing.TraceInfo("Found standard feed document");
                // found the feed......
                // now parse the source base of this element
                ParseSource(reader, feed);

                // feed parsing complete, send notfication
                this.OnNewAtomEntry(feed);
            } else if (localname.Equals(this.nameTable.Entry)) {
                Tracing.TraceInfo("Found entry document");
                ParseEntry(reader);
            } else {
                Tracing.TraceInfo("ParseFeed called and nothing was parsed" + localname.ToString());
                // throw new ClientFeedException("An invalid Atom Document was passed to the parser. Neither Feed nor Entry started the document"); 
            }
            OnParsingDone();
            feed.MarkElementDirty(false);
        }
Esempio n. 19
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a batch upload test</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseBatchUpdates()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchUpdates");

            FeedQuery query = new FeedQuery();
            Service service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);
                // this should have a batch URI
                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI"); 


                AtomFeed batchFeed = new AtomFeed(baseFeed);

                // set the default operation. 
                batchFeed.BatchData = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.delete; 

                int i = 1; 
                foreach (AtomEntry entry in baseFeed.Entries)
                {
                    AtomEntry batchEntry = batchFeed.Entries.CopyOrMove(entry); 

                    batchEntry.BatchData = new GDataBatchEntryData();
                    batchEntry.BatchData.Id = i.ToString(); 
                    batchEntry.BatchData.Type = GDataBatchOperationType.update; 
                    batchEntry.Title.Text = "Updated"; 

                }





                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));

                foreach (AtomEntry resultEntry in resultFeed.Entries )
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    Assert.IsTrue(data.Status.Code == 200, "Status code should be 200, is:" + data.Status.Code);
                }
            }
        }
Esempio n. 20
0
 /// <summary>
 /// takes a given feed, and does a batch post of that feed
 /// against the batchUri parameter. If that one is NULL
 /// it will try to use the batch link URI in the feed
 /// </summary>
 /// <param name="feed">the feed to post</param>
 /// <param name="batchUri">the URI to user</param>
 /// <returns>the returned AtomFeed</returns>
 public AtomFeed Batch(AtomFeed feed, Uri batchUri)
 {
     return(Batch(feed, batchUri, null));
 }
Esempio n. 21
0
        /// <summary>
        /// templated type safe version of Insert
        /// </summary>
        /// <typeparam name="TEntry"></typeparam>
        /// <param name="feed"></param>
        /// <param name="entry"></param>
        /// <returns> the new Entry, as returned from the server</returns>
        public TEntry Insert <TEntry>(AtomFeed feed, TEntry entry) where TEntry : AtomEntry
        {
            IService s = this as IService;

            return(s.Insert(feed, entry) as TEntry);
        }
Esempio n. 22
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test of batch support on the events feed</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarBatchTest()
        {
            Tracing.TraceMsg("Entering CalendarBatchTest");

            CalendarService service = new CalendarService(this.ApplicationName);

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                EventQuery query = new EventQuery(this.defaultCalendarUri);

                EventFeed feed = service.Query(query);
                AtomFeed batchFeed = new AtomFeed(feed);

                string newEntry1Title = "new event" + Guid.NewGuid().ToString();
                EventEntry newEntry1 = new EventEntry(newEntry1Title);
                newEntry1.BatchData = new GDataBatchEntryData("1", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(newEntry1);

                string newEntry2Title = "new event" + Guid.NewGuid().ToString();
                EventEntry newEntry2 = new EventEntry(newEntry2Title);
                newEntry2.BatchData = new GDataBatchEntryData("2", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(newEntry2);

                string newEntry3Title = "new event" + Guid.NewGuid().ToString();
                EventEntry newEntry3 = new EventEntry(newEntry3Title);
                newEntry3.BatchData = new GDataBatchEntryData("3", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(newEntry3);

                Tracing.TraceMsg("Creating batch items");

                EventFeed batchResultFeed = (EventFeed)service.Batch(batchFeed, new Uri(feed.Batch));

                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    Assert.IsNotNull(evt.BatchData, "Result should contain batch information.");
                    Assert.IsNotNull(evt.BatchData.Id, "Result should have a Batch ID.");
                    Assert.AreEqual(201, evt.BatchData.Status.Code, "Created entries should return 201");
 
                    switch (evt.BatchData.Id)
                    {
                        case "1":
                            Assert.AreEqual(newEntry1Title, evt.Title.Text, "titles should be equal.");
                            break;
                        case "2":
                            Assert.AreEqual(newEntry2Title, evt.Title.Text, "titles should be equal.");
                            break;
                        case "3":
                            Assert.AreEqual(newEntry3Title, evt.Title.Text, "titles should be equal.");
                            break;
                        default:
                            Assert.Fail("Unrecognized entry in result of batch insert feed");
                            break;
                    }

                }

                Tracing.TraceMsg("Updating created entries.");

                batchFeed = new AtomFeed(feed);
                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    evt.BatchData = new GDataBatchEntryData(evt.BatchData.Id, GDataBatchOperationType.update);
                    evt.Title.Text = evt.Title.Text + "update";
                    batchFeed.Entries.Add(evt);
                }

                batchResultFeed = (EventFeed) service.Batch(batchFeed, new Uri(feed.Batch));

                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    Assert.IsNotNull(evt.BatchData, "Result should contain batch information.");
                    Assert.IsNotNull(evt.BatchData.Id, "Result should have a Batch ID.");
                    Assert.AreEqual(200, evt.BatchData.Status.Code, "Updated entries should return 200");

                    switch (evt.BatchData.Id)
                    {
                        case "1":
                            Assert.AreEqual(newEntry1Title + "update", evt.Title.Text, "titles should be equal.");
                            break;
                        case "2":
                            Assert.AreEqual(newEntry2Title + "update", evt.Title.Text, "titles should be equal.");
                            break;
                        case "3":
                            Assert.AreEqual(newEntry3Title + "update", evt.Title.Text, "titles should be equal.");
                            break;
                        default:
                            Assert.Fail("Unrecognized entry in result of batch update feed");
                            break;
                    }

                }



                Tracing.TraceMsg("Deleting created entries.");

                batchFeed = new AtomFeed(feed);
                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    evt.BatchData = new GDataBatchEntryData(GDataBatchOperationType.delete);
                    evt.Id = new AtomId(evt.EditUri.ToString());
                    batchFeed.Entries.Add(evt);
                }

                batchResultFeed = (EventFeed)service.Batch(batchFeed, new Uri(feed.Batch));

                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    Assert.AreEqual(200, evt.BatchData.Status.Code, "Deleted entries should return 200");
                }

                service.Credentials = null;
            }
        }
Esempio n. 23
0
 public void BatchDataTest()
 {
     AtomFeed target = new AtomFeed(new Uri("http://www.test.com/"), null); 
     GDataBatchFeedData expected = new GDataBatchFeedData(); 
     GDataBatchFeedData actual;
     target.BatchData = expected;
     actual = target.BatchData;
     Assert.AreEqual(expected, actual);
 }
 public AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomFeed feed, SendOrPostCallback callback, object userData)
     : this(handler, uriToUse, null, feed, callback, userData, false)
 {
 }
Esempio n. 25
0
 public void EntriesTest()
 {
     AtomFeed target = new AtomFeed(new Uri("http://www.test.com/"), null); 
     Assert.IsNotNull(target.Entries);
 }
 private AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomEntry entry, AtomFeed feed, SendOrPostCallback callback, object userData, bool parseFeed)
     : base(uriToUse, null, userData, callback, parseFeed)
 {
     this.DataHandler = handler;
     this.entry       = entry;
     this.Feed        = feed;
 }
Esempio n. 27
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>virtual, starts the parsing process</summary> 
        /// <param name="streamInput">input stream to parse </param>
        /// <param name="feed">the basefeed object that should be set</param>
        //////////////////////////////////////////////////////////////////////
        public abstract void Parse(Stream streamInput, AtomFeed feed); 
Esempio n. 28
0
        public void GoogleBaseBatchInsert()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchUpload");

            FeedQuery query = new FeedQuery();
            Service service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory; 



                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);

                // this should have a batch URI

                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI"); 

                AtomFeed batchFeed = new AtomFeed(new Uri(this.gBaseURI), service);

                // set the default operation. Unneeded, as the default is insert, 
                // but want to make sure the code is complete
                batchFeed.BatchData = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.delete; 

      

                for (int i=0; i<20; i++)
                {
                    AtomEntry entry = ObjectModelHelper.CreateGoogleBaseEntry(i);
                    entry.BatchData = new GDataBatchEntryData();

                    entry.BatchData.Type = GDataBatchOperationType.insert; 
                    entry.BatchData.Id = i.ToString();
                 
                    batchFeed.Entries.Add(entry); 
                }

                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));

                foreach (AtomEntry resultEntry in resultFeed.Entries )
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    Assert.IsTrue(data.Status.Code == 201, "Status code should be 201, is:" + data.Status.Code);
                }
            }
        }
Esempio n. 29
0
 public void TotalResultsTest()
 {
     AtomFeed target = new AtomFeed(new Uri("http://www.test.com/"), null); 
     int expected = 5; // TODO: Initialize to an appropriate value
     int actual;
     target.TotalResults = expected;
     actual = target.TotalResults;
     Assert.AreEqual(expected, actual);
 }
Esempio n. 30
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a batch upload test</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseBatchMix()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchMix");

            FeedQuery query = new FeedQuery();
            Service service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);
                // this should have a batch URI
                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI"); 

                AtomFeed batchFeed = new AtomFeed(baseFeed);

                // set the default operation. 
                batchFeed.BatchData = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.insert; 

                int id = 1; 
                bool fUpdate = true; 
                foreach (AtomEntry entry in baseFeed.Entries)
                {
                    AtomEntry batchEntry = batchFeed.Entries.CopyOrMove(entry); 

                    if (fUpdate==true)
                    {
                        batchEntry.BatchData = new GDataBatchEntryData();
                        batchEntry.BatchData.Id = id.ToString(); 
                        batchEntry.BatchData.Type = GDataBatchOperationType.update; 
                        batchEntry.Title.Text = "Updated"; 
                        fUpdate = false;

                    }
                    else 
                    {

                        batchEntry.BatchData = new GDataBatchEntryData();
                        batchEntry.BatchData.Id = id.ToString(); 
                        batchEntry.BatchData.Type = GDataBatchOperationType.delete; 
                        fUpdate = true;
                    }


                    // insert one
                    id++; 
                    batchEntry = ObjectModelHelper.CreateGoogleBaseEntry(1);
                    batchEntry.BatchData = new GDataBatchEntryData();
                    batchEntry.BatchData.Type = GDataBatchOperationType.insert; 
                    batchEntry.BatchData.Id = id.ToString();
                    batchFeed.Entries.Add(batchEntry); 
                    id++; 
                }





                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));

                foreach (AtomEntry resultEntry in resultFeed.Entries )
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    int testcode = 200; 
                    if (data.Type == GDataBatchOperationType.insert)
                    {
                        testcode = 201; 
                    }
                    Assert.IsTrue(data.Status.Code == testcode, "Status code should be: " + testcode + ", is:" + data.Status.Code);
                }
            }
        }
Esempio n. 31
0
 /// <summary>constructor</summary> 
 public AtomEntryCollection(AtomFeed feed) : base()
 {
     this.feed = feed; 
 }
        /// <summary>
        /// parses the current position in the xml reader and fills 
        /// the provided GDataFeedBatch property on the feed object
        /// </summary>
        /// <param name="reader">the xmlreader positioned at a batch element</param>
        /// <param name="feed">the atomfeed object to fill in</param>
        protected void ParseBatch(XmlReader reader, AtomFeed feed) {
            if (reader == null) {
                throw new ArgumentNullException("reader");
            }
            if (feed == null) {
                throw new ArgumentNullException("feed");
            }

            if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace)) {
                object elementName = reader.LocalName;

                if (feed.BatchData == null) {
                    feed.BatchData = new GDataBatchFeedData();
                }

                GDataBatchFeedData batch = feed.BatchData;

                if (elementName.Equals(this.nameTable.BatchOperation)) {
                    batch.Type = (GDataBatchOperationType)Enum.Parse(typeof(GDataBatchOperationType),
                        reader.GetAttribute(BaseNameTable.XmlAttributeType), true);
                } else {
                    Tracing.TraceInfo("got an unknown batch element: " + elementName.ToString());
                    reader.Skip();
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>starts the parsing process</summary> 
        /// <param name="streamInput">input stream to parse </param>
        /// <param name="feed">the feed object to construct</param>
        //////////////////////////////////////////////////////////////////////
        public override void Parse(Stream streamInput, AtomFeed feed)
        {
            

            
        }
Esempio n. 34
0
 /// <summary>internal method to set the feed</summary> 
 internal void setFeed(AtomFeed feed) {
     if (feed != null) {
         this.Dirty = true;
         this.Service = feed.Service;
     }
     this.feed = feed;
 }
        /// <summary>parses xml to fill a precreated AtomSource object (might be a feed)</summary>
        /// <param name="reader">correctly positioned reader</param>
        /// <param name="source">created source object to be filled</param>
        /// <returns> </returns>
        protected void ParseSource(XmlReader reader, AtomSource source)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            Tracing.Assert(source != null, "source should not be null");
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            Tracing.TraceCall();

            int depth = -1;

            ParseBasicAttributes(reader, source);

            while (NextChildElement(reader, ref depth))
            {
                object   localname = reader.LocalName;
                AtomFeed feed      = source as AtomFeed;
                if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom))
                {
                    if (localname.Equals(this.nameTable.Title))
                    {
                        source.Title = ParseTextConstruct(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Updated))
                    {
                        source.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Link))
                    {
                        source.Links.Add(ParseLink(reader, source));
                    }
                    else if (localname.Equals(this.nameTable.Id))
                    {
                        source.Id = source.CreateAtomSubElement(reader, this) as AtomId;
                        ParseBaseLink(reader, source.Id);
                    }
                    else if (localname.Equals(this.nameTable.Icon))
                    {
                        source.Icon = source.CreateAtomSubElement(reader, this) as AtomIcon;
                        ParseBaseLink(reader, source.Icon);
                    }
                    else if (localname.Equals(this.nameTable.Logo))
                    {
                        source.Logo = source.CreateAtomSubElement(reader, this) as AtomLogo;
                        ParseBaseLink(reader, source.Logo);
                    }
                    else if (localname.Equals(this.nameTable.Author))
                    {
                        source.Authors.Add(ParsePerson(reader, source));
                    }
                    else if (localname.Equals(this.nameTable.Contributor))
                    {
                        source.Contributors.Add(ParsePerson(reader, source));
                    }
                    else if (localname.Equals(this.nameTable.Subtitle))
                    {
                        source.Subtitle = ParseTextConstruct(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Rights))
                    {
                        source.Rights = ParseTextConstruct(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Generator))
                    {
                        source.Generator = ParseGenerator(reader, source);
                    }
                    else if (localname.Equals(this.nameTable.Category))
                    {
                        // need to make this another colleciton
                        source.Categories.Add(ParseCategory(reader, source));
                    }
                    else if (feed != null && localname.Equals(this.nameTable.Entry))
                    {
                        ParseEntry(reader);
                    }
                    // this will either move the reader to the end of an element
                    // if at the end, to the start of a new one.
                    reader.Read();
                }
                else if (feed != null && IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace))
                {
                    // parse the google batch extensions if they are there
                    ParseBatch(reader, feed);
                }
                else if (feed != null && IsCurrentNameSpace(reader, BaseNameTable.OpenSearchNamespace(this.versionInfo)))
                {
                    if (localname.Equals(this.nameTable.TotalResults))
                    {
                        feed.TotalResults = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.StartIndex))
                    {
                        feed.StartIndex = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.ItemsPerPage))
                    {
                        feed.ItemsPerPage = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                }
                else
                {
                    // default extension parsing.
                    ParseExtensionElements(reader, source);
                }
            }
            return;
        }
Esempio n. 36
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>default constructor so that FxCop does not complain</summary>
        //////////////////////////////////////////////////////////////////////
        public GDataBatchRequestException(AtomFeed batchResult)
        {
            this.batchResult = batchResult;
        }
Esempio n. 37
0
        private BlogEntry MapEntry(AtomEntry entry, AtomFeed comments)
        {
            BlogEntry blogEntry = MapEntry(entry);

            blogEntry.Comments = new List<Comment>();

            foreach (AtomEntry atomComment in comments.Entries)
            {
                Comment comment = new Comment();
                comment.Content = atomComment.Content.Content;
                comment.PubDate = atomComment.Published;
                comment.Author = atomComment.Authors[0].Name;
                comment.id = CommentIdRegex.Match(atomComment.SelfUri.Content).Groups["commentid"].Value;
                blogEntry.Comments.Add(comment);
            }

            return blogEntry;
        }
Esempio n. 38
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>overloaded to make eventfiring easier</summary> 
        /// <param name="feed"> the new feed to fire</param>
        //////////////////////////////////////////////////////////////////////
        protected void OnNewAtomEntry(AtomFeed feed)
        {
            FeedParserEventArgs args = new FeedParserEventArgs(feed, null);
            this.OnNewAtomEntry(args);
        }
Esempio n. 39
0
 /// <summary>constructor</summary>
 public AtomEntryCollection(AtomFeed feed)
     : base()
 {
     this.feed = feed;
 }
Esempio n. 40
0
        private static void DisplayFeed(AtomFeed myFeed)
        {
            foreach (AtomEntry entry in myFeed.Entries)
            {

                System.Diagnostics.Debug.WriteLine(entry.Id.AbsoluteUri + ", ");
            }
        }
Esempio n. 41
0
        public void FeedTest()
        {
            Uri uri = new Uri("http://www.test.com/");
            IService service = new Service();
            ServiceEventArgs target = new ServiceEventArgs(uri, service); // TODO: Initialize to an appropriate value

            AtomFeed expected = new AtomFeed(uri, service);
            AtomFeed actual;
            target.Feed = expected;
            actual = target.Feed;
            Assert.AreEqual(expected, actual);
        }
Esempio n. 42
0
        /// <summary>public AtomSource(AtomFeed feed)</summary> 
        public AtomSource(AtomFeed feed)
            : this() {
            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null) {
                throw new ArgumentNullException("feed");
            }

            // now copy them
            this.authors = feed.Authors;
            this.contributors = feed.Contributors;
            this.categories = feed.Categories;
            this.Generator = feed.Generator;
            this.Icon = feed.Icon;
            this.Logo = feed.Logo;
            this.Id = feed.Id;
            this.links = feed.Links;
            this.Rights = feed.Rights;
            this.Subtitle = feed.Subtitle;
            this.Title = feed.Title;
            this.Updated = feed.Updated;
        }
Esempio n. 43
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>virtual, starts the parsing process</summary>
        /// <param name="streamInput">input stream to parse </param>
        /// <param name="feed">the basefeed object that should be set</param>
        //////////////////////////////////////////////////////////////////////
        public abstract void Parse(Stream streamInput, AtomFeed feed);