コード例 #1
0
        public List <Result> Query(Query query)
        {
            foreach (var programArgumentParser in _programArgumentParsers)
            {
                if (!programArgumentParser.Enabled)
                {
                    continue;
                }

                if (!programArgumentParser.TryParse(query, out var program, out var programArguments))
                {
                    continue;
                }

                var results1 = _win32ProgramRepository.AsParallel()
                               .Where(p => p.Enabled)
                               .Select(p => p.Result(program, programArguments, _context.API));

                var results2 = _packageRepository.AsParallel()
                               .Where(p => p.Enabled)
                               .Select(p => p.Result(program, programArguments, _context.API));

                var result = results1.Concat(results2).Where(r => r != null && r.Score > 0);
                if (result.Any())
                {
                    var maxScore = result.Max(x => x.Score);
                    result = result.Where(x => x.Score > Settings.MinScoreThreshold * maxScore);
                }

                return(result.ToList());
            }

            return(new List <Result>(0));
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: zw790138065/PowerToys
        public List <Result> Query(Query query)
        {
            var results1 = _win32ProgramRepository.AsParallel()
                           .Where(p => p.Enabled)
                           .Select(p => p.Result(query.Search, _context.API));

            var results2 = _packageRepository.AsParallel()
                           .Where(p => p.Enabled)
                           .Select(p => p.Result(query.Search, _context.API));

            var result = results1.Concat(results2).Where(r => r != null && r.Score > 0).ToList();

            return(result);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: xxzhan321/PowerToys
        public List <Result> Query(Query query)
        {
            var results1 = _win32ProgramRepository.AsParallel()
                           .Where(p => p.Enabled)
                           .Select(p => p.Result(query.Search, _context.API));

            var results2 = _packageRepository.AsParallel()
                           .Where(p => p.Enabled)
                           .Select(p => p.Result(query.Search, _context.API));

            var result   = results1.Concat(results2).Where(r => r != null && r.Score > 0);
            var maxScore = result.Max(x => x.Score);

            result = result.Where(x => x.Score > Settings.MinScoreThreshold * maxScore);

            return(result.ToList());
        }
コード例 #4
0
        public List <Result> Query(Query query)
        {
            Programs.Win32[] win32;

            lock (IndexLock)
            {
                // just take the reference inside the lock to eliminate query time issues.
                win32 = _win32s;
            }

            var results1 = win32.AsParallel()
                           .Where(p => p.Enabled)
                           .Select(p => p.Result(query.Search, _context.API));

            var results2 = _packageRepository.AsParallel()
                           .Where(p => p.Enabled)
                           .Select(p => p.Result(query.Search, _context.API));

            var result = results1.Concat(results2).Where(r => r != null && r.Score > 0).ToList();

            return(result);
        }