public virtual IEnumerable <WoxResult> GetResults(WoxQuery query) => MatchCommands(query, 0, CommandInfos, string.Empty);
protected IEnumerable <WoxResult> MatchCommands(WoxQuery query, int position, IEnumerable <CommandInfo> commandInfos, string path) { var results = new List <WoxResult>(); var term = query.GetTermOrEmpty(position); foreach (var commandInfo in commandInfos) { var commandName = commandInfo.Name; var newPath = commandName; if (!string.IsNullOrEmpty(path)) { newPath = path + WoxContextService.Seperater + commandName; } if (commandName.MatchPattern(term)) { if (term == commandName) { if (commandInfo.FinalAction != null) { results.Add(GetActionResult(commandInfo.Title, commandInfo.Subtitle, commandInfo.FinalAction)); } else if (commandInfo.ResultGetter != null) { var subCommandResults = commandInfo.ResultGetter(query, position + 1); if (subCommandResults != null) { results.AddRange(subCommandResults); } } else { var subCommandResults = MatchCommands(query, position + 1, GetCommandInfos(newPath), newPath); if (subCommandResults != null) { results.AddRange(subCommandResults); } } } else { if (query.SearchTerms.Length <= position + 1) { var result = GetEmptyCommandResult(commandInfo); if (result != null) { results.Add(result); } } } } } if (results.Count == 0) { var commandInfo = GetDefaultCommandInfo(path); if (commandInfo != null) { var commandResults = commandInfo.ResultGetter(query, position); if (commandResults != null) { results.AddRange(commandResults); } } else { results.Add(GetEmptyCommandResult(path, commandInfos)); } } return(results); }