/// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { DatabaseSetup.AddDatabaseSetup(services, Configuration); IdentitySetup.AddIdentitySetup(services, Configuration); AuthenticationJwtSetup.AddAuthenticationJwtSetup(services, Configuration); AutoMapperSetup.AddAutoMapperSetup(services); DependencyInjectionSetup.AddDependencyInjectionSetup(services); SwaggerSetup.AddSwaggerSetup(services); // Determinar que a api vai chamar uma determinada controller services.AddMvc(options => { // configuração que obrigar que seja informado uma autenticação // garante que todas as requests sejam autenticadas var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) // Configuração para não retorna referencia cicular no json .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddCors(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //Setup para configuração do Swagger SwaggerSetup.AddSwaggerSetup(services); //Setup para configuração do EF EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration); //Setup para o JWT JwtBearerSetup.AddJwtBearerSetup(services, Configuration); //Setup para MongoDB MongoDbSetup.AddMongoDbSetup(services, Configuration); //Injecao de dependencia DependenxyInjection.Register(services); //Setup para MediatR MediatRSetup.AddMediatRSetup(services); //Setup para AutoMapper AutoMapperSetup.AddAutoMapperSetup(services); //Setup para o CORS CorsSetup.AddCorsSetup(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); SwaggerSetup.AddSwaggerSetup(services); DependencyInjection.Register(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton(Configuration); AutoMapperSetup.AddAutoMapperSetup(services); SwaggerSetup.AddSwaggerSetup(services); DependencyInjectionSetup.AddDependencyInjectionSetup(services, Configuration); ApiSetup.AddApiSetup(services, Configuration); }
public void ConfigureServices(IServiceCollection services) { services.AddDbContext <SqlContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DbTodoProject"))); services.AddTransient <IItemRepository, ItemRepository>(); services.AddCors(); services.AddControllers(); SwaggerSetup.AddSwaggerSetup(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration); DependencyInjection.Register(services); AutoMapperSetup.AddAutoMapperSetup(services); CorsSetup.AddCorsSetup(services); SwaggerSetup.AddSwaggerSetup(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //Swagger configration setup SwaggerSetup.AddSwaggerSetup(services); //EntityFrmework configuration setup EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration); //Mediator configration setup MediatorSetup.AddMediatorSettup(services); //Dependency Injection DependencyInjection.Register(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Ativando o uso de cache via Redis services.AddDistributedRedisCache(options => { options.Configuration = Configuration.GetConnectionString("ConexaoRedis"); options.InstanceName = "TesteRedisCache"; }); services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddDbContext <DataContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("connectionString"))); services.AddScoped <IAuthorRepository, AuthorRepository>(); services.AddScoped <IBookRepository, BooksRepository>(); services.AddScoped <ICacheRepository, CacheRepository>(); services.AddScoped <AuthorHandler, AuthorHandler>(); services.AddScoped <BooksHandler, BooksHandler>(); services.AddScoped <IMediatorHandler, RabbitMQueue>(); services.AddScoped <IAuthorQueries, AuthorQueries>(); services.AddScoped <IBookQueries, BookQueries>(); services.AddScoped <ICacheService, CacheService>(); //var mappingConfig = new MapperConfiguration(mc => // { // mc.AddProfile(new MappingProfile()); // }); // IMapper mapper = mappingConfig.CreateMapper(); // services.AddSingleton(mapper); //Setup para Swagger SwaggerSetup.AddSwaggerSetup(services); //Setup para AutoMapper AutoMapperSetup.AddAutoMapperSetup(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //setup para configuração Swagger.. SwaggerSetup.AddSwaggerSetup(services); //setup para configuração do EntityFramework.. EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration); //setup para configuração de injeção de dependencia.. InjecaoDependencia.Registrar(services); //setup para JWT Bearer.. JwtBearerSetup.AddJwtBearerSetup(services, Configuration); //setup para MongoDB.. MongoDBSetup.AddMongoDBSetup(services, Configuration); //setup para MediatR.. MediatRSetup.AddMediatRSetup(services); //setup para AutoMapper.. AutoMapperSetup.AddAutoMapperSetup(services); //Setup para o Cors CorsSetup.AddCorsSetup(services); }