Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs
Hongtao Zhang 000c45bfa8
Refactor Explorer Code to fit the new architecture
1. Rename some method in QueryConstructor.cs by removing prefix and suffix
2. Split the logic of checking '>' to outer SearchManager.cs
3. Use IAsyncEnumerable for potential future improvement.
2022-09-10 10:45:41 -05:00

52 lines
1.8 KiB
C#

using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Flow.Launcher.Plugin.Explorer.Search.IProvider;
namespace Flow.Launcher.Plugin.Explorer.Search.Everything
{
public class EverythingSearchManager : IIndexProvider, IContentIndexProvider, IPathIndexProvider
{
private Settings Settings { get; }
public EverythingSearchManager(Settings settings)
{
Settings = settings;
}
public IAsyncEnumerable<SearchResult> SearchAsync(string search, CancellationToken token)
{
return EverythingApi.SearchAsync(
new EverythingSearchOption(search, Settings.SortOption),
token);
}
public IAsyncEnumerable<SearchResult> ContentSearchAsync(string plainSearch,
string contentSearch, CancellationToken token)
{
if (!Settings.EnableEverythingContentSearch)
{
return AsyncEnumerable.Empty<SearchResult>();
}
return EverythingApi.SearchAsync(
new EverythingSearchOption(
plainSearch,
Settings.SortOption,
true,
contentSearch),
token);
}
public IAsyncEnumerable<SearchResult> EnumerateAsync(string path, string search, bool recursive, CancellationToken token)
{
return EverythingApi.SearchAsync(
new EverythingSearchOption(search,
Settings.SortOption,
ParentPath: path,
IsRecursive: recursive),
token);
}
}
}