/// <summary> /// Gets an individual oEmbed. /// </summary> /// <param name="client">The client.</param> /// <param name="url">The URL.</param> /// <param name="providerFilter">The provider filter.</param> /// <param name="options">The options.</param> /// <returns></returns> public static Result GetOEmbed(this Client client, Uri url, Func<Provider, bool> providerFilter, RequestOptions options) { return GetOEmbeds(client, new[] { url }, providerFilter, options).FirstOrDefault(); }
/// <summary> /// Gets an individual oEmbed. /// </summary> /// <param name="client">The client.</param> /// <param name="url">The URL.</param> /// <param name="options">The options.</param> /// <returns></returns> public static Result GetOEmbed(this Client client, Uri url, RequestOptions options) { return GetOEmbed(client, url, null, options); }
/// <summary> /// Gets multiple oEmbeds /// </summary> /// <param name="client">The client.</param> /// <param name="urls">The urls.</param> /// <param name="providerFilter">The provider filter.</param> /// <param name="options">The options.</param> /// <returns></returns> public static IEnumerable<Result> GetOEmbeds(this Client client, IEnumerable<Uri> urls, Func<Provider, bool> providerFilter, RequestOptions options) { if (urls == null) throw new ArgumentNullException("urls"); if (options == null) throw new ArgumentNullException("options"); var results = new BlockingCollection<Result>(); var redirector = new RequestObserver(client, options); redirector.Output.Subscribe(results.Add, results.CompleteAdding); var requests = urls .ToObservable(NewThreadScheduler.Default) .Select(u => u.MakeUrlRequests(client)) .WhereProvider(providerFilter); requests.Subscribe(redirector); return results.GetConsumingEnumerable(); }
/// <summary> /// Gets multiple oEmbeds /// </summary> /// <param name="client">The client.</param> /// <param name="urls">The urls.</param> /// <param name="providerFilter">The provider filter.</param> /// <param name="options">The options.</param> /// <returns></returns> public static IObservable<Result> GetOEmbeds(this Client client, IObservable<Uri> urls, Func<Provider, bool> providerFilter, RequestOptions options) { if (urls == null) throw new ArgumentNullException("urls"); if (options == null) throw new ArgumentNullException("options"); var requests = urls .ObserveOn(NewThreadScheduler.Default) .Select(u => u.MakeUrlRequests(client)) .WhereProvider(providerFilter); var redirector = new RequestObserver(client, options); requests.Subscribe(redirector); return redirector.Output; }
/// <summary> /// Gets multiple oEmbeds /// </summary> /// <param name="client">The client.</param> /// <param name="urls">The urls.</param> /// <param name="options">The options.</param> /// <returns></returns> public static IEnumerable<Result> GetOEmbeds(this Client client, IEnumerable<Uri> urls, RequestOptions options) { return GetOEmbeds(client, urls, null, options); }