public async Task <bool> MoveNextAsync() { if (engineTypes.MoveNext()) { var provider = (ISearchProvider)scope.ServiceProvider.GetRequiredService(engineTypes.Current); current = await provider.SearchAsync(Keyword, Index *Take, Take); } return(false); }
public static async Task <SearchComicResult> SearchAsync(this SearchEngine eng, string keyword, int skip, int take) { using (var scope = eng.ServiceScopeFactory.CreateScope()) { var result = new SearchComicResult { Total = 0 }; var datas = new List <ComicSnapshot>(); foreach (var item in eng) { var prov = (ISearchProvider)scope.ServiceProvider.GetRequiredService(item); var dt = await prov.SearchAsync(keyword, skip, take); if (dt != null && dt.Support && dt.Snapshots != null) { result.Support = dt.Support; datas.AddRange(dt.Snapshots); result.Total += dt.Total; } } result.Snapshots = datas.ToArray(); return(result); } }