Ejemplo n.º 1
0
        /// <summary>eventhandler - called for event extension element
        /// </summary>
        /// <param name="sender">the object which send the event</param>
        /// <param name="e">FeedParserEventArguments, holds the feedEntry</param>
        /// <returns> </returns>
        protected void OnNewExtensionsElement(object sender, ExtensionElementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            AtomFeedParser parser = sender as AtomFeedParser;

            if (e.Base.XmlName == AtomParserNameTable.XmlAtomEntryElement)
            {
                // the base is the Entry of the feed, let's call our parsing on the Entry
                AtomEntry entry = e.Base as AtomEntry;
                if (entry != null)
                {
                    entry.Parse(e, parser);
                }
            }
            else
            {
                HandleExtensionElements(e, parser);
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 public AsyncSendData(AsyncDataHandler handler, AtomEntry entry, SendOrPostCallback callback, object userData)
     : this(handler, null, entry, null, callback, userData, false)
 {
 }
Ejemplo n.º 4
0
        public void DeleteAsync(AtomEntry entry, bool permanentDelete, Object userData)
        {
            AsyncDeleteData data = new AsyncDeleteData(entry, permanentDelete, userData, ProgressReportDelegate);

            AsyncStarter(data, AsyncDeleteWorker, userData);
        }
Ejemplo n.º 5
0
 public AsyncDeleteData(AtomEntry entry, bool permanentDelete, object userData, SendOrPostCallback callback)
     : base(null, userData, callback)
 {
     _entry           = entry;
     _permanentDelete = permanentDelete;
 }
        /// <summary>reads one of the feed entries at a time</summary>
        /// <param name="reader"> XmlReader positioned at the entry element</param>
        /// <returns> notifies user using event mechanism</returns>
        public void ParseEntry(XmlReader reader)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            object localname = reader.LocalName;

            Tracing.TraceCall("Parsing atom entry");
            if (localname.Equals(_nameTable.Entry) == false)
            {
                throw new ClientFeedException("trying to parse an atom entry, but reader is not at the right spot");
            }

            AtomEntry entry = OnCreateNewEntry();

            ParseBasicAttributes(reader, entry);

            // remember the depth of entry
            int depth = -1;

            while (NextChildElement(reader, ref depth))
            {
                localname = reader.LocalName;

                if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom))
                {
                    if (localname.Equals(_nameTable.Id))
                    {
                        entry.Id = entry.CreateAtomSubElement(reader, this) as AtomId;
                        ParseBaseLink(reader, entry.Id);
                    }
                    else if (localname.Equals(_nameTable.Link))
                    {
                        entry.Links.Add(ParseLink(reader, entry));
                    }
                    else if (localname.Equals(_nameTable.Updated))
                    {
                        entry.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(_nameTable.Published))
                    {
                        entry.Published = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(_nameTable.Author))
                    {
                        entry.Authors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(_nameTable.Contributor))
                    {
                        entry.Contributors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(_nameTable.Rights))
                    {
                        entry.Rights = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(_nameTable.Category))
                    {
                        AtomCategory category = ParseCategory(reader, entry);
                        entry.Categories.Add(category);
                    }
                    else if (localname.Equals(_nameTable.Summary))
                    {
                        entry.Summary = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(_nameTable.Content))
                    {
                        entry.Content = ParseContent(reader, entry);
                    }
                    else if (localname.Equals(_nameTable.Source))
                    {
                        entry.Source = entry.CreateAtomSubElement(reader, this) as AtomSource;
                        ParseSource(reader, entry.Source);
                    }
                    else if (localname.Equals(_nameTable.Title))
                    {
                        entry.Title = ParseTextConstruct(reader, entry);
                    }

                    // all parse methods should leave the reader at the end of their element
                    reader.Read();
                }
                else if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace))
                {
                    // parse the google batch extensions if they are there
                    ParseBatch(reader, entry);
                }
                else
                {
                    // default extension parsing
                    ParseExtensionElements(reader, entry);
                }
            }

            OnNewAtomEntry(entry);

            return;
        }
Ejemplo n.º 7
0
        /// <summary>overloaded to make it easier to fire the event</summary>
        /// <param name="newEntry">the new AtomEntry to fire </param>
        protected void OnNewAtomEntry(AtomEntry newEntry)
        {
            FeedParserEventArgs args = new FeedParserEventArgs(null, newEntry);

            OnNewAtomEntry(args);
        }
Ejemplo n.º 8
0
 /// <summary>Inserts an AtomBase entry against a Uri</summary>
 /// <param name="feedUri">the uri for the feed this object should be posted against</param>
 /// <param name="baseEntry">the entry to be inserted</param>
 /// <param name="type">the type of request to create</param>
 /// <returns> the response as a stream</returns>
 public Stream EntrySend(Uri feedUri, AtomEntry baseEntry, GDataRequestType type)
 {
     return(EntrySend(feedUri, baseEntry, type, null));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// internal Insert version to avoid recursion in the template versions
 /// </summary>
 /// <param name="feedUri"></param>
 /// <param name="newEntry"></param>
 /// <returns></returns>
 protected AtomEntry internalInsert(Uri feedUri, AtomEntry newEntry)
 {
     return(Insert(feedUri, newEntry, null));
 }
Ejemplo n.º 10
0
 /// <summary>WebResponse Update(Uri updateUri, Stream entryStream, ICredentials credentials)</summary>
 /// <param name="entry">the old entry to update</param>
 /// <returns> the new Entry, as returned from the server</returns>
 public AtomEntry Update(AtomEntry entry)
 {
     return(Update(entry, null));
 }
Ejemplo n.º 11
0
 /// <summary>deletes an Atom entry object</summary>
 /// <param name="entry"> </param>
 public void Delete(AtomEntry entry)
 {
     Delete(entry, false);
 }