示例#1
0
        internal List <Result> Search(Query query)
        {
            var results = new List <Result>();

            var querySearch = query.Search;

            if (IsFileContentSearch(query.ActionKeyword))
            {
                return(WindowsIndexFileContentSearch(query, querySearch));
            }

            // This allows the user to type the assigned action keyword and only see the list of quick folder links
            if (settings.QuickFolderAccessLinks.Count > 0 &&
                query.ActionKeyword == settings.SearchActionKeyword &&
                string.IsNullOrEmpty(query.Search))
            {
                return(quickFolderAccess.FolderListAll(query, settings.QuickFolderAccessLinks, context));
            }

            var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context);

            if (quickFolderLinks.Count > 0)
            {
                results.AddRange(quickFolderLinks);
            }

            var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);

            if (isEnvironmentVariable)
            {
                return(EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query, context));
            }

            // Query is a location path with a full environment variable, eg. %appdata%\somefolder\
            var isEnvironmentVariablePath = querySearch.Substring(1).Contains("%\\");

            if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath)
            {
                results.AddRange(WindowsIndexFilesAndFoldersSearch(query, querySearch));

                return(results);
            }

            var locationPath = querySearch;

            if (isEnvironmentVariablePath)
            {
                locationPath = EnvironmentVariables.TranslateEnvironmentVariablePath(locationPath);
            }

            if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)))
            {
                return(results);
            }

            var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);

            results.Add(resultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));

            results.AddRange(TopLevelDirectorySearchBehaviour(WindowsIndexTopLevelFolderSearch,
                                                              DirectoryInfoClassSearch,
                                                              useIndexSearch,
                                                              query,
                                                              locationPath));

            return(results);
        }