public async Task <ContentPage> SearchAsync(ContentSearchOptions options, CancellationToken cancellationToken) { if (options is null) { throw new ArgumentNullException(nameof(options)); } var search = await this.client.SearchAsync(new API.FreeSoundSearchOptions { Query = options.Query, Page = options.Page }, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); return(new ContentPage { Entries = search.Results?.Select(ToEntry).ToArray() ?? Array.Empty <AudioContentEntry> () }); }
public PaginatedContentSource(Func <ContentEntry, object> getViewModel, IContentProviderService service, ContentSearchOptions options, ContentPage initialPage) { if (initialPage is null) { throw new ArgumentNullException(nameof(initialPage)); } this.getViewModel = getViewModel; this.service = service ?? throw new ArgumentNullException(nameof(service)); this.options = options ?? throw new ArgumentNullException(nameof(options)); this.items.AddRange(initialPage.Entries.Select(e => getViewModel(e))); this.pageSize = initialPage.Entries.Count; }