// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            services.AddDbContext <CrawlerContext>(options =>
            {
                options.UseSqlServer(Configuration.GetConnectionString("CrawlerDatabase"));
                options.UseLoggerFactory(DebugLoggerFactory);
                options.EnableSensitiveDataLogging();
            }
                                                   );

            //services.AddSingleton<>()

            var esConnectionOptions = new EsConnectionOptions();

            Configuration.GetSection(EsConnectionOptions.EsConnection).Bind(esConnectionOptions);
            services.AddSingleton(esConnectionOptions);
        }
示例#2
0
 public SearchController(ILogger <SearchController> logger, CrawlerContext db, EsConnectionOptions esConnectionOptions)
 {
     _logger = logger;
     this.db = db;
     _esConnectionOptions = esConnectionOptions;
 }