Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddJsonOptions(
                options =>
            {
                options.SerializerSettings.ContractResolver = new DefaultContractResolver()
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };
            });

            var botConfiguration = new BotConfiguration
            {
                BotToken = EnvironmentVariables.GetEnvironmentVariable(EnvironmentVariables.BotToken)
            };
            var container = new Container(rules => rules.WithoutThrowOnRegisteringDisposableTransient());

            container.UseInstance(botConfiguration);

            Ioc.Services.Load(container);

            var serviceProvider = container.WithDependencyInjectionAdapter(services, throwIfUnresolved: type => true);

            Container = serviceProvider.BuildServiceProvider();
            return(Container);
        }