Ejemplo n.º 1
0
        public static IHostBuilder ConfigureServices(this IHostBuilder hostBuilder)
        {
            return(hostBuilder.ConfigureServices((_, collection) =>
            {
                collection.Scan(scan =>
                {
                    scan.FromAssemblyOf <IPaginator>()
                    .AddClasses()
                    .AsSelf()
                    .WithSingletonLifetime();

                    scan.FromAssemblyOf <IBotCommand>()
                    .AddClasses(x => x.AssignableTo <IBotCommand>())
                    .As <IBotCommand>()
                    .WithSingletonLifetime();

                    scan.FromAssemblyOf <IBotStateHandler>()
                    .AddClasses(x => x.AssignableTo <IBotStateHandler>())
                    .As <IBotStateHandler>()
                    .WithSingletonLifetime();

                    scan.FromAssemblyOf <IBotCallbackQuery>()
                    .AddClasses(x => x.AssignableTo <IBotCallbackQuery>())
                    .As <IBotCallbackQuery>()
                    .WithSingletonLifetime();
                });

                collection.AddSingleton <IDigitalOceanClient>(_ => new DigitalOceanClient(EnvironmentVars.GetDigitalOceanToken()));
                collection.AddSingleton <StorageService>();
                collection.AddSingleton <BotCommandResolver>();
            }));
        }