Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        /// <summary>helper method to create a new, decoupled entry based on a feedEntry</summary>
        /// <param name="entryToImport">the entry from a feed that you want to put somewhere else</param>
        /// <returns> the new entry ready to be inserted</returns>
        public static AtomEntry ImportFromFeed(AtomEntry entryToImport)
        {
            Tracing.Assert(entryToImport != null, "entryToImport should not be null");
            if (entryToImport == null)
            {
                throw new ArgumentNullException("entryToImport");
            }

            AtomEntry entry = null;

            entry = (AtomEntry)Activator.CreateInstance(entryToImport.GetType());
            entry.CopyEntry(entryToImport);

            entry.Id = null;

            // if the source is empty, set the source to the old feed

            if (entry.Source == null)
            {
                entry.Source = entryToImport.Feed;
            }
            Tracing.TraceInfo("Imported entry: " + entryToImport.Title.Text + " to: " + entry.Title.Text);
            return(entry);
        }
Exemplo n.º 3
0
 /// <summary>deletes an Atom entry object</summary>
 /// <param name="entry"> </param>
 public void Delete(AtomEntry entry)
 {
     Delete(entry, false);
 }
Exemplo n.º 4
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(this.EntrySend(feedUri, baseEntry, type, null));
 }
Exemplo n.º 5
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(this.Insert(feedUri, newEntry, null));
 }
Exemplo n.º 6
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(this.Update(entry, null));
 }
Exemplo n.º 7
0
        public void DeleteAsync(AtomEntry entry, bool permanentDelete, Object userData)
        {
            AsyncDeleteData data = new AsyncDeleteData(entry, permanentDelete, userData, ProgressReportDelegate);

            AsyncStarter(data, AsyncDeleteWorker, userData);
        }
Exemplo n.º 8
0
 public AsyncSendData(AsyncDataHandler handler, AtomEntry entry, SendOrPostCallback callback, object userData)
     : this(handler, null, entry, null, callback, userData, false)
 {
 }
Exemplo n.º 9
0
 public AsyncDeleteData(AtomEntry entry, bool permanentDelete, object userData, SendOrPostCallback callback)
     : base(null, userData, callback)
 {
     _entry           = entry;
     _permanentDelete = permanentDelete;
 }
Exemplo n.º 10
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);

            this.OnNewAtomEntry(args);
        }
Exemplo n.º 11
0
        /// <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(this.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(this.nameTable.Id))
                    {
                        entry.Id = entry.CreateAtomSubElement(reader, this) as AtomId;
                        ParseBaseLink(reader, entry.Id);
                    }
                    else if (localname.Equals(this.nameTable.Link))
                    {
                        entry.Links.Add(ParseLink(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Updated))
                    {
                        entry.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Published))
                    {
                        entry.Published = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Author))
                    {
                        entry.Authors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Contributor))
                    {
                        entry.Contributors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Rights))
                    {
                        entry.Rights = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Category))
                    {
                        AtomCategory category = ParseCategory(reader, entry);
                        entry.Categories.Add(category);
                    }
                    else if (localname.Equals(this.nameTable.Summary))
                    {
                        entry.Summary = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Content))
                    {
                        entry.Content = ParseContent(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Source))
                    {
                        entry.Source = entry.CreateAtomSubElement(reader, this) as AtomSource;
                        ParseSource(reader, entry.Source);
                    }
                    else if (localname.Equals(this.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;
        }