-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSearcher.cs
33 lines (28 loc) · 1.15 KB
/
Searcher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PickAll
{
/// <summary>Represents a searching service managed by <c>SearchContext</c>.</summary>
public abstract class Searcher : Service
{
public Searcher(object settings)
{
Settings = settings;
Name = GetType().Name;
}
internal event EventHandler<ResultHandledEventArgs> ResultCreated;
/// <summary>The searcher identifier set to class name.</summary>
public string Name { get; private set; }
/// <summary>Performs the actual search and returns a sequence of <c>ResultInfo</c>.</summary>
public abstract Task<IEnumerable<ResultInfo>> SearchAsync(string query);
protected ResultInfo CreateResult(
int index, string url, string description, object data = null)
{
var result = new ResultInfo(Name, index, url, description, data);
EventHelper.RaiseEvent(this, ResultCreated,
() => new ResultHandledEventArgs(result, ServiceType.Searcher), Context.Settings.EnableRaisingEvents);
return result;
}
}
}