Esempio n. 1
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureServices(service => {
            service.AddDistributedRedisCache(options => {
                options.Configuration = Env.RedisConnString;
            });
            service.AddDbContext <SearchContext>(options => options.UseNpgsql(SearchContext.Configuring), ServiceLifetime.Transient);
            service.AddSingleton <ITelegramBotClient>(sp => string.IsNullOrEmpty(Env.HttpProxy) ? new TelegramBotClient(Env.BotToken) : new TelegramBotClient(Env.BotToken, new WebProxy(Env.HttpProxy)));
            service.AddTransient <SendService>();
            service.AddSingleton <SendMessage>();

            service.AddTransient <SonicSearchService>();
            service.AddTransient <SearchService>();
            service.AddTransient <MessageService>();
            service.AddTransient <AutoQRService>();
            service.AddTransient <AutoOCRService>();
            service.AddTransient <RefreshService>();
            AddController(service);
        });