Ejemplo n.º 1
0
 public static void AddSearchProvider(this SearchEngine searchEng)
 {
     searchEng.Add(typeof(SomanSearchProvider));
     searchEng.Add(typeof(Dm5SearchProvider));
     searchEng.Add(typeof(BilibiliSearchProvider));
     searchEng.Add(typeof(KuaikanSearchProvider));
 }
Ejemplo n.º 2
0
        public async Task Handle(NewsAddEvent @event)
        {
            var news = @event.News;

            if (news.Category == null)
            {
                news.Category = _context.Categories.SingleOrDefault(c => c.Id == news.CategoryId);
            }

            await _searchEngine.Add(@event.News);
        }
Ejemplo n.º 3
0
        private SearchEngine CreateEng()
        {
            var factory = new ValueServiceScopeFactory();

            factory.Factory = new Dictionary <Type, Func <object> >
            {
                [typeof(DataSearchProvider)] = () => new DataSearchProvider
                {
                    Datas = new Dictionary <string, SearchComicResult>
                    {
                        ["aaa"] = new SearchComicResult
                        {
                            Snapshots = new ComicSnapshot[]
                            {
                                new ComicSnapshot
                                {
                                    Name     = "aaa",
                                    Author   = "aa",
                                    Descript = "aaaaa",
                                    ImageUri = "aaaaaaaaa",
                                    Sources  = new ComicSource[]
                                    {
                                        new ComicSource {
                                            Name = "ss1", TargetUrl = "ssurl"
                                        },
                                        new ComicSource(),
                                    },
                                    TargetUrl = "aaaaaaaaaa"
                                },
                                new ComicSnapshot()
                            },
                            Support = true,
                            Total   = 2
                        }
                    }
                },
                [typeof(DataSearchProvider2)] = () => new DataSearchProvider
                {
                    Datas = new Dictionary <string, SearchComicResult>
                    {
                        ["bbb"] = new SearchComicResult
                        {
                            Snapshots = new ComicSnapshot[]
                            {
                                new ComicSnapshot
                                {
                                    Name     = "bbb",
                                    Author   = "bb",
                                    Descript = "aaabbbaa",
                                    ImageUri = "bb",
                                    Sources  = new ComicSource[]
                                    {
                                        new ComicSource {
                                            Name = "ss1", TargetUrl = "ssurl"
                                        },
                                        new ComicSource(),
                                    },
                                    TargetUrl = "bbbbbbb"
                                },
                                new ComicSnapshot()
                            },
                            Support = true,
                            Total   = 11
                        }
                    }
                }
            };
            var eng = new SearchEngine(factory);

            eng.Add(typeof(DataSearchProvider));
            eng.Add(typeof(DataSearchProvider2));
            return(eng);
        }