/// <summary> /// Get related events by wikipedia id in one time. /// </summary> /// <param name="wikipediaId">The specific wikipedia id to be queried on. </param> /// <param name="top">The number of events to be returned. /// <para>E.g., if top is 5, the first 5 events will be returned. If not specified, the service will return all the events related to that wikipedia id.</para></param> /// <param name="skip">The number of events to be skipped. /// <para>E.g., if skip is 5, the first 5 events will be skipped. If not specified, the service will not skip any events.</para></param> /// <returns>Related Events of the specific wikipedia id.</returns> public IEnumerable <Event> GetRelatedEvents(string wikipediaId, int?top = null, int?skip = null) { if (string.IsNullOrWhiteSpace(wikipediaId)) { throw new ArgumentNullException(nameof(wikipediaId)); } string nextLink = null; do { var requestUri = string.IsNullOrWhiteSpace(nextLink) ? FormatQuery(RelatedEventsQuery, "wikipediaid", wikipediaId, top, skip) : nextLink; var result = SyncUtility.RunWithoutSynchronizationContext(() => { var task = GetAsync <string, EventResponse>(requestUri, null).ConfigureAwait(false); return(task.GetAwaiter().GetResult()); }); nextLink = result.NextLink; foreach (var eventItem in result.Value) { yield return(eventItem); } } while (!string.IsNullOrWhiteSpace(nextLink)); }
/// <summary> /// Get related documents of the specific event in one time. /// </summary> /// <param name="eventId">The specific event id to be queried on. </param> /// <param name="top">The number of documents to be returned. /// <para>E.g., if top is 5, the first 5 documents will be returned. If not specified, the service will return all the documents in that event.</para></param> /// <param name="skip">The number of documents to be skipped. /// <para>E.g., if skip is 5, the first 5 documents will be skipped. If not specified, the service will not skip any documents.</para></param> /// <returns>Related documents of the specific event.</returns> public IEnumerable <Document> GetEventDetail(string eventId, int?top = null, int?skip = null) { if (string.IsNullOrWhiteSpace(eventId)) { throw new ArgumentNullException(nameof(eventId)); } string nextLink = null; do { var queryPath = new StringBuilder(); queryPath.AppendFormat("{0}/{1}/{2}", EventDetailQuery1, Uri.EscapeDataString(eventId), EventDetailQuery2); var requestUri = string.IsNullOrWhiteSpace(nextLink) ? FormatQuery(queryPath.ToString(), "eventid", eventId, top, skip) : nextLink; var result = SyncUtility.RunWithoutSynchronizationContext(() => { var task = GetAsync <string, DocumentResponse>(requestUri, null).ConfigureAwait(false); return(task.GetAwaiter().GetResult()); }); nextLink = result.NextLink; foreach (var docItem in result.Value) { yield return(docItem); } } while (!string.IsNullOrWhiteSpace(nextLink)); }
/// <summary> /// Get hot events by date in one time. /// </summary> /// <param name="date">The specific date to be queried on.</param> /// <param name="top">The number of events to be returned. /// <para>E.g., if top is 5, the first 5 events will be returned. If not specified, the service will return all the events on that date.</para></param> /// <param name="skip">The number of events to be skipped. /// <para>E.g., if skip is 5, the first 5 events will be skipped. If not specified, the service will not skip any events.</para></param> /// <returns>Hot Events on the specific date.</returns> public IEnumerable <Event> GetHotEvents(DateTimeOffset date, int?top = null, int?skip = null) { string nextLink = null; do { var requestUri = string.IsNullOrWhiteSpace(nextLink) ? FormatQuery(HotEventsQuery, "date", GetUtcDate(date), top, skip) : nextLink; var result = SyncUtility.RunWithoutSynchronizationContext(() => { var task = GetAsync <string, EventResponse>(requestUri, null).ConfigureAwait(false); return(task.GetAwaiter().GetResult()); }); nextLink = result.NextLink; foreach (var eventItem in result.Value) { yield return(eventItem); } } while (!string.IsNullOrWhiteSpace(nextLink)); }