コード例 #1
0
        public ViewResult Index(string query, string category, int?page, string language, int?period)
        {
            var categories        = _categoryProvider.Get();
            var videoNewsProvider = _videoNewsProvider.Get();
            var languages         = _languageProvider.Get();

            return
                (View(new NewsViewModel(videoNewsProvider, categories, languages, query, category, page, language, period)));
        }
コード例 #2
0
        protected override async Task QueryAsync(IQuery query, CancellationToken ct)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Available(new EverythingNotAvailableResult("Everything is only available on Windows"));
                return;
            }

            var everythingStatus = _everything.GetStatus();

            if (!everythingStatus.IsRunning)
            {
                var notRunning = new WebResult
                {
                    Icon        = EverythingIcon.EverythingLogo,
                    Title       = "Everything not running",
                    Description = "Not installed? Execute this result to go to download page",
                    Uri         = new Uri("https://www.voidtools.com/downloads/")
                };

                Available(notRunning);

                while (!_everything.GetStatus().IsRunning)
                {
                    await Task.Delay(TimeSpan.FromSeconds(1), ct);
                }

                Expired(notRunning);
                if (!_everything.GetStatus().IsDatabaseLoaded)
                {
                    var dbLoading = new EverythingNotAvailableResult("Everything is starting up")
                    {
                        Icon        = EverythingIcon.EverythingLogo,
                        Description = "This may take a few seconds",
                    };

                    Available(dbLoading);
                    while (!_everything.GetStatus().IsDatabaseLoaded)
                    {
                        await Task.Delay(TimeSpan.FromSeconds(1), ct);
                    }
                    Expired(dbLoading);
                }
            }

            SearchResult result;

            using (_logger.Timed("Search everything for {rawQuery}", query.Argument))
            {
                result = await _everything.SearchAsync(query.Argument, _searchOption, ct);
            }

            ct.ThrowIfCancellationRequested();


            foreach (var item in result.Items)
            {
                Available(new EverythingResult
                {
                    Title       = item.Name,
                    Description = item.FullPath,
                    Category    = _category.Get(item),
                    FullPath    = item.FullPath,
                    Icon        = new Image
                    {
                        Alt = item.Name,
                        Uri = (item is FileResultItem)
              ? new Uri($"/icons/{item.FullPath}", UriKind.Relative)
              : EverythingIcon.FolderIcon.Uri
                    }
                });
            }
        }
コード例 #3
0
 public IEnumerable <Category> Get()
 {
     return(categoryProvider.Get());
 }