Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <FakeUserRepository>();

            // Configures JWT Authentication
            JwtServiceConfiguration.ConfigureAuthenticationServices(services, this.Configuration);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc().AddControllersAsServices();

            var nlogConfiguration = Configuration.GetSection("NLog").Get <NLogConfiguration>();

            NLogServiceConfiguration.ConfigureNLog(nlogConfiguration);

            ConfigurationDtoConfiguration.ConfigureConfigurationDto(services, Configuration);

            var connectionString = Configuration.GetConnectionString("eSuiteConnection");

            DbContextOptionsConfiguration.ConfigureDbContextOptions(services, connectionString);

            var corsConfiguration = Configuration.GetSection("Cors").Get <CorsConfiguration>();

            CorsServiceConfiguration.ConfigureCorsService(services, corsConfiguration);

            var jwtConfiguration = Configuration.GetSection("Jwt").Get <JwtConfiguration>();

            JwtServiceConfiguration.ConfigureJwtService(services, jwtConfiguration);

            var swaggerConfiguration = Configuration.GetSection("Swagger").Get <SwaggerConfiguration>();

            SwaggerServiceConfiguration.ConfigureSwaggerService(services, swaggerConfiguration);

            var rawRabbitConfiguration = Configuration.GetSection("RawRabbit").Get <RawRabbitConfiguration>();

            RawRabbitServiceConfiguration.ConfigureRawRabbit(services, rawRabbitConfiguration);

            AuthorizationConfiguration.ConfigureAuthorization(services);
            AutoMapperConfiguration.ConfigureAutoMapper();

            // Create the container builder.
            var builder = new ContainerBuilder();

            builder.Populate(services);

            /*  Register here all modules, type*/
            builder.RegisterModule <EFModule <eSuiteDbContext> >();

            var autofacConfiguration = Configuration.GetSection("Autofac").Get <AutofacConfiguration>();

            builder.RegisterModule(new StandardModule {
                AssemblyNames = autofacConfiguration.CandidateAssemblies
            });

            ApplicationContainer = builder.Build();

            // Create the IServiceProvider based on the container.
            return(new AutofacServiceProvider(ApplicationContainer));
        }