2013-12-19 15:51:20 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace WinAlfred.Plugin
|
|
|
|
|
{
|
|
|
|
|
public class Query
|
|
|
|
|
{
|
|
|
|
|
public string RawQuery { get; set; }
|
|
|
|
|
public string ActionName { get; private set; }
|
|
|
|
|
public List<string> ActionParameters { get; private set; }
|
|
|
|
|
|
|
|
|
|
public Query(string rawQuery)
|
|
|
|
|
{
|
|
|
|
|
RawQuery = rawQuery;
|
2013-12-20 11:38:10 +00:00
|
|
|
|
ActionParameters = new List<string>();
|
2013-12-19 15:51:20 +00:00
|
|
|
|
ParseQuery();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ParseQuery()
|
|
|
|
|
{
|
2013-12-20 11:38:10 +00:00
|
|
|
|
if (string.IsNullOrEmpty(RawQuery)) return;
|
|
|
|
|
|
|
|
|
|
string[] strings = RawQuery.Split(' ');
|
2013-12-21 16:44:56 +00:00
|
|
|
|
if (strings.Length == 1) return; //we consider a valid query must contain a space
|
|
|
|
|
|
2013-12-20 11:38:10 +00:00
|
|
|
|
ActionName = strings[0];
|
2013-12-21 16:44:56 +00:00
|
|
|
|
for (int i = 1; i < strings.Length; i++)
|
2013-12-20 11:38:10 +00:00
|
|
|
|
{
|
2013-12-21 16:44:56 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(strings[i]))
|
2013-12-20 11:38:10 +00:00
|
|
|
|
{
|
|
|
|
|
ActionParameters.Add(strings[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-19 15:51:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|