Пример #1
0
        private async void Search2 <TBroker>()
            where TBroker : ISearchBroker, new()
        {
            repos.Clear();
            paths.Clear();
            var broker = new SearchRepositoriesBroker();

            //using (var dialog = new SearchCriteriaForm { SelectedObject = broker })
            //	if (dialog.ShowDialog(this) == DialogResult.OK)

            broker.Term  = "IdealAutomatex";
            searchResult = await CreateSearcher(broker).SearchAsync();

            //searchResult = searcher.Search();
            foreach (var item in ((SearchResult <Octokit.Repository>)(searchResult)).Items)
            {
                repos.Add(item.Owner.Login + "/" + item.Name);
                Console.WriteLine(item.Name);
            }
            //	BeginWork(BackgroundType.Search, CreateSearcher(broker));
            // ((SearchResult<Octokit.Repository>)(searchResult)).Items


            var brokerx = new SearchCodeBroker();

            using (var dialog = new SearchCriteriaForm {
                SelectedObject = brokerx
            })
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    int totalCount = 0;
                    foreach (var item in repos)
                    {
                        brokerx.Repos = item;
                        searchResult  = await CreateSearcher(brokerx).SearchAsync();

                        //searchResult = searcher.Search();
                        foreach (var itemx in ((SearchResult <Octokit.SearchCode>)(searchResult)).Items)
                        {
                            totalCount++;
                            paths.Add(itemx);
                            // paths.Add(itemx.Repository.FullName + "/" + itemx.Path);
                            Console.WriteLine(itemx.Repository.FullName + "/" + itemx.Path);
                        }
                    }
                    SearchResult <Octokit.SearchCode> bigSearchResult = new SearchResult <SearchCode>(totalCount, false,
                                                                                                      new ReadOnlyCollection <SearchCode>(paths));

                    mainDataGridView.DataSource = null;
                    this.searcher = CreateSearcher(brokerx);
                    mainDataGridView.DataSource = bigSearchResult.DataSource;
                }
            CompleteSearch();
        }
Пример #2
0
        private void Search <TBroker>()
            where TBroker : ISearchBroker, new()
        {
            var broker = new TBroker();

            using (var dialog = new SearchCriteriaForm {
                SelectedObject = broker
            })
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    BeginWork(BackgroundType.Search, CreateSearcher(broker));
                }
        }