/// <summary>Constructor, given a category as a string from the URI.</summary> public QueryCategory(string strCategory, QueryCategoryOperator op) { Tracing.TraceMsg("Depersisting category from: " + strCategory); _categoryOperator = op; strCategory = FeedQuery.CleanPart(strCategory); // let's parse the string if (strCategory[0] == '-') { // negator _isExcluded = true; // remove him strCategory = strCategory.Substring(1, strCategory.Length - 1); } // let's extract the scheme if there is one... int iStart = strCategory.IndexOf('{'); int iEnd = strCategory.IndexOf('}'); AtomUri scheme = null; if (iStart != -1 && iEnd != -1) { iEnd++; iStart++; scheme = new AtomUri(strCategory.Substring(iStart, iEnd - iStart - 1)); // the rest is then strCategory = strCategory.Substring(iEnd, strCategory.Length - iEnd); } Tracing.TraceMsg("Category found: " + strCategory + " - scheme: " + scheme); _category = new AtomCategory(strCategory, scheme); }
/// <summary>Passing in a complete URI, we strip all the /// GData query-related things and then treat the rest /// as the base URI. For this we create a service.</summary> /// <param name="uri">a complete URI</param> /// <param name="service">the new GData service for this URI</param> /// <param name="query">the parsed query object for this URI</param> public static void Parse(Uri uri, out Service service, out FeedQuery query) { query = new FeedQuery(); query.ParseUri(uri); service = new Service(); }
/// <summary> /// Returns a single Atom entry based upon its unique URI. /// </summary> /// <param name="entryUri">The URI of the Atom entry.</param> /// <returns>AtomEntry representing the entry.</returns> public AtomEntry Get(string entryUri) { FeedQuery query = new FeedQuery(entryUri); AtomFeed resultFeed = Query(query); return(resultFeed.Entries[0]); }
/// <summary> /// helper method to setup a query object with some parameters /// based on a requestsettings /// </summary> /// <param name="q"></param> /// <param name="settings"></param> internal static void PrepareQuery(FeedQuery q, RequestSettings settings) { if (settings.PageSize != -1) { q.NumberToRetrieve = settings.PageSize; } if (settings.OAuthUser != null) { q.OAuthRequestorId = settings.OAuthUser; if (settings.OAuthDomain != null) { q.OAuthRequestorId += "@" + settings.OAuthDomain; } } }
/// <summary> /// helper to format a DateTime parameter into the query /// </summary> /// <param name="value"></param> /// <param name="parameterName"></param> /// <param name="connect"></param> /// <param name="builder"></param> /// <returns></returns> protected static char AppendQueryPart(DateTime value, string parameterName, char connect, StringBuilder builder) { if (builder == null) { throw new ArgumentNullException("builder"); } if (builder.ToString().IndexOf(parameterName + "=") == -1) { if (Utilities.IsPersistable(value)) { return(FeedQuery.AppendQueryPart(Utilities.LocalDateTimeInUTC(value), parameterName, connect, builder)); } } return(connect); }
/// <summary>executes the query and returns an AtomFeed object tree</summary> /// <param name="feedQuery">the query parameters as a FeedQuery object </param> /// <returns>AtomFeed object tree</returns> public AtomFeed Query(FeedQuery feedQuery) { AtomFeed feed = null; Tracing.TraceCall("Enter"); if (feedQuery == null) { throw new System.ArgumentNullException("feedQuery", "The query argument MUST not be null"); } // Create a new request to the Uri in the query object... Uri targetUri = null; try { targetUri = feedQuery.Uri; } catch (System.UriFormatException) { throw new System.ArgumentException("The query argument MUST contain a valid Uri", "feedQuery"); } Tracing.TraceInfo("Service:Query - about to query"); Stream responseStream = null; if (feedQuery.Etag != null) { responseStream = Query(targetUri, feedQuery.Etag); } else { responseStream = Query(targetUri, feedQuery.ModifiedSince); } Tracing.TraceInfo("Service:Query - query done"); if (responseStream != null) { feed = CreateAndParseFeed(responseStream, feedQuery.Uri); } Tracing.TraceCall("Exit"); return(feed); }
public AtomFeed Query(FeedQuery feedQuery, DateTime ifModifiedSince) { feedQuery.ModifiedSince = ifModifiedSince; return(Query(feedQuery)); }