[PowerToys Run] Plugin manager (#9872)

This commit is contained in:
Mykhailo Pylyp
2021-02-26 13:21:58 +02:00
committed by GitHub
parent f839a408de
commit 4a9e920a1c
66 changed files with 749 additions and 276 deletions

View File

@@ -19,19 +19,32 @@ namespace Wox.Plugin
/// Initializes a new instance of the <see cref="Query"/> class.
/// to allow unit tests for plug ins
/// </summary>
public Query(string rawQuery, string search, ReadOnlyCollection<string> terms, string actionKeyword = "")
public Query(string query, string actionKeyword = "")
{
Search = search;
RawQuery = rawQuery;
Terms = terms;
_query = query;
ActionKeyword = actionKeyword;
}
private string _rawQuery;
/// <summary>
/// Gets raw query, this includes action keyword if it has
/// We didn't recommend use this property directly. You should always use Search property.
/// </summary>
public string RawQuery { get; internal set; }
public string RawQuery
{
get
{
if (_rawQuery == null)
{
_rawQuery = string.Join(Query.TermSeparator, _query.Split(new[] { TermSeparator }, StringSplitOptions.RemoveEmptyEntries));
}
return _rawQuery;
}
}
private string _search;
/// <summary>
/// Gets search part of a query.
@@ -39,12 +52,41 @@ namespace Wox.Plugin
/// Since we allow user to switch a exclusive plugin to generic plugin,
/// so this property will always give you the "real" query part of the query
/// </summary>
public string Search { get; internal set; }
public string Search
{
get
{
if (_search == null)
{
_search = RawQuery.Substring(ActionKeyword.Length).Trim();
}
return _search;
}
}
private ReadOnlyCollection<string> _terms;
/// <summary>
/// Gets the raw query splited into a string array.
/// </summary>
public ReadOnlyCollection<string> Terms { get; private set; }
public ReadOnlyCollection<string> Terms
{
get
{
if (_terms == null)
{
var terms = _query
.Trim()
.Substring(ActionKeyword.Length)
.Split(new[] { TermSeparator }, StringSplitOptions.RemoveEmptyEntries);
_terms = new ReadOnlyCollection<string>(terms);
}
return _terms;
}
}
/// <summary>
/// Query can be splited into multiple terms by whitespace
@@ -102,6 +144,8 @@ namespace Wox.Plugin
}
}
private string _query;
public override string ToString() => RawQuery;
[Obsolete("Use Search instead, this method will be removed in v1.3.0")]