/// <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); }
/// <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; }
/// <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)); }
/// <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)); }
/// <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); }
/// <summary> /// default constructor that takes the underlying atomfeed /// </summary> /// <param name="af"></param> public Feed(AtomFeed af) { this.af = af; }
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; }
public AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomFeed feed, SendOrPostCallback callback, object userData) : this(handler, uriToUse, null, feed, callback, userData, false) { }
/// <summary>constructor</summary> public AtomEntryCollection(AtomFeed feed) : base() { this.feed = feed; }
/// <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>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);
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>default constructor so that FxCop does not complain</summary> ////////////////////////////////////////////////////////////////////// public GDataBatchRequestException(AtomFeed batchResult) { this.batchResult = batchResult; }
/// <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.NSOpenSearchRss) || IsCurrentNameSpace(reader, BaseNameTable.NSOpenSearch11))) { 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; }