Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.WithOrigins("http://localhost:4200");
                });
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "4Asset API", Version = "v1"
                });
            });


            services.AddCors(options =>
            {
                options.AddPolicy("AllowMyOrigin",
                                  builder => builder.WithOrigins("http://localhost:4200"));
            });

            NativeInjectorBootStrapper.RegisterServices(services);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //services.ConfigureSwaggerGen(x =>
            //{
            //    x.OperationFilter<AuthorizationHeaderParameterOperationFilter>();
            //    x.OperationFilter<ProducesOperatioFilter>();
            //    x.OperationFilter<FormFileSwaggerFilter>();
            //});

            //Configuração do Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v1",
                    Title          = "API Modelo",
                    Description    = "Exemplo de API usando padrão DDD",
                    TermsOfService = "None",
                    Contact        = new Contact
                    {
                        Name  = "Estêvão Braga",
                        Email = string.Empty,
                        Url   = "https://github.com/estevaobraga"
                    }
                });
            });

            //Injeções de dependencia
            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
Beispiel #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Optimal);

            services.AddResponseCompression();

            services.AddMvc()
            .AddJsonOptions(opt =>
            {
                opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            });

            services.AddCors();

            //Auto mapper
            services.AddAutoMapper();

            //Configuração do Swagger (Documentação)
            services.AddSwaggerGen(x =>
            {
                x.SwaggerDoc("v1", new Info {
                    Title = "TESTE - BLUDATA", Version = "v1"
                });

                var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "api-bludata.application.webapi.xml");
                x.IncludeXmlComments(filePath);
                x.OperationFilter <ExamplesOperationFilter>();
            });

            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Registrar todos os DI
            NativeInjectorBootStrapper.RegisterServices(services);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Beispiel #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddOpenTelemetryTracing((builder) =>
            {
                builder
                .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(Configuration.GetValue <string>("Jaeger:ServiceName")))
                .AddHttpClientInstrumentation()
                .AddAspNetCoreInstrumentation()
                .AddEntityFrameworkCoreInstrumentation(config => config.SetDbStatementForText = true)
                .AddJaegerExporter(config =>
                {
                    Configuration.GetSection("Jaeger").Bind(config);
                });
            });
            //it doesn's work ,so use 'Bind'
            services.Configure <JaegerExporterOptions>(Configuration.GetSection("Jaeger"));
            services.AddLogDashboard();
            //启动配置
            services.AddAutoMapperSetup();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "DDD project", Version = "v1"
                });
            });
            services.AddMediatR(typeof(Startup), typeof(Example.Domain.CommandHandlers.CommandHandler));

            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //services.AddAutoMapperSetup();

            services.AddSwaggerGen(s =>
            {
                s.SwaggerDoc("v1", new Info
                {
                    Version     = "v1",
                    Title       = "Exago Project",
                    Description = "Exago API Swagger surface",
                    Contact     = new Contact {
                        Name = "André Santos", Email = "*****@*****.**"
                    },
                });
            });

            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));

            services.AddAutoMapper(typeof(AutoMapperConfig));
            // Registering Mappings automatically only works if the
            // Automapper Profile classes are in ASP.NET project
            //AutoMapperConfig.RegisterMappings();

            // .NET Native DI Abstraction
            // Adding dependencies from another layers (isolated from Presentation)
            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
Beispiel #7
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            IServiceCollection services = new ServiceCollection();

            services.AddDbContext <ReviewDBContext>(c =>
                                                    c.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Integrated Security=true;Initial Catalog=ReviewDB;"));

            services.AddMediatR(typeof(MovieCommandHandler).GetTypeInfo().Assembly);
            services.AddAutoMapper();

            // Registering Mappings automatically only works if the
            // Automapper Profile classes are in ASP.NET project
            AutoMapperConfig.RegisterMappings();

            NativeInjectorBootStrapper.RegisterServices(services);

            _provider = services
                        .BuildServiceProvider();

            var movieAppService = _provider.GetService <IMovieAppService>();

            LoadJsonAsync();
        }
Beispiel #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //MongoDbContext.ConnectionString = Configuration.GetSection("MongoConnection:ConnectionString").Value;
            //MongoDbContext.DatabaseName = Configuration.GetSection("MongoConnection:Database").Value;
            //MongoDbContext.IsSSL = Convert.ToBoolean(this.Configuration.GetSection("MongoConnection:IsSSL").Value);


            services.AddDbContext <RHContext>(options =>
                                              options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddDbContext <EventStoreSqlContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));


            services.AddMediatR(typeof(Startup));
            services.AddControllers();
            services.AddSwaggerExtension("RH", "1.0");

            // ASP.NET HttpContext dependency
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            // .NET Native DI Abstraction
            //services.AddDependencyInjectionSetup();
            NativeInjectorBootStrapper.RegisterServices(services);

            services.AddRabbitMQEventBus("amqp://localhost", eventBusOptionAction: eventBusOption =>
            {
                eventBusOption.ClientProvidedAssembly <Startup>();
                eventBusOption.EnableRetryOnFailure(true, 5000, TimeSpan.FromSeconds(30));
                eventBusOption.RetryOnFailure(TimeSpan.FromSeconds(1));
            }, "guest");
        }
Beispiel #9
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("v1", new OpenApiInfo {
             Title = "Rukiye Doðru", Version = "v1"
         });
     });
     services.AddLogging(loggingBuilder =>
     {
         loggingBuilder.AddConfiguration(Configuration.GetSection("NlogConnection"));
         loggingBuilder.AddConsole();
         loggingBuilder.AddDebug();
     });
     services.AddDbContext <Core3BaseContext>(options =>
                                              options.UseSqlServer(
                                                  Configuration.GetConnectionString("DefaultConnection")));
     services.AddDbContext <AdminIdentityContext>(options =>
                                                  options.UseSqlServer(
                                                      Configuration.GetConnectionString("DefaultConnection")));
     NativeInjectorBootStrapper.RegisterServices(services);
     NativeInjectorBootStrapper.RegisterFileHelper(services,
                                                   Configuration["FileServerUrl"]);
     services.AddControllersWithViews()
     .AddNewtonsoftJson(options =>
                        options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                        );
     services.AddControllers();
 }
Beispiel #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(HttpGlobalExceptionFilter));
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .ConfigureApiBehaviorOptions(options =>
            {
                options.SuppressModelStateInvalidFilter = true;
            })
            .AddFluentValidation();

            services.AddDbContext <PaymentContext>(options => options.UseInMemoryDatabase(databaseName: "PaymentApi"));
            services.AddAutoMapper(typeof(Startup));
            Application.AutoMapper.AutoMapperConfig.RegisterMappings();

            services.AddSwaggerGen(s =>
            {
                s.SwaggerDoc("v1", new Info
                {
                    Version     = "v1",
                    Title       = "MeiFacil.Payment",
                    Description = "MeiFacil Payment API",
                    Contact     = new Contact {
                        Name = "Valdir Moreira", Email = "*****@*****.**", Url = "https://www.meifacil.com/"
                    },
                    License = new License {
                        Name = "PRIVATE", Url = string.Empty
                    }
                });
            });

            NativeInjectorBootStrapper.RegisterServices(services);
        }
Beispiel #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            NativeInjectorBootStrapper.Services(services, Configuration.GetConnectionString("DefaultConnection"));

            services.AddMvc()
            .AddMvcOptions(options =>
            {
                options.Filters.Add(new ProducesAttribute("application/json"));
            })
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new StringEnumConverter());
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                options.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddCors(options =>
            {
                options.AddPolicy("AllowFront", builder =>
                                  builder.WithOrigins("http://localhost:4200")
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials()
                                  );
            });
        }
Beispiel #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddResponseCompression(options =>
            {
                options.Providers.Add <GzipCompressionProvider>();
            });

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

            // Registering Mappings automatically only works if the
            // Automapper Profile classes are in ASP.NET project
            AutoMapperConfig.RegisterMappings();

            services.AddControllers()
            .AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = null;
                options.JsonSerializerOptions.DictionaryKeyPolicy  = null;
            });

            // .NET Native DI Abstraction
            // Adding dependencies from another layers (isolated from Presentation)
            NativeInjectorBootStrapper.RegisterServices(services);

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "SGBB API", Version = "v1"
                });
            });
        }
Beispiel #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddOptions();

            services.AddMvc(options =>
            {
                options.OutputFormatters.Remove(new XmlDataContractSerializerOutputFormatter());
                options.UseCentralRoutePrefix(new RouteAttribute("api/v{version:apiVersion}/"));
            });


            services.AddAutoMapper(typeof(MappingProfile));

            services.AddApiVersioning();
            services.AddSwaggerGen(c =>
            {
                c.EnableAnnotations();
                c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); //This line
                c.SwaggerDoc("rhgestao", new OpenApiInfo {
                    Title = "RhGestão", Version = Configuration["Prefs:ApiVersion"]
                });
            });

            // Register all DI
            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
Beispiel #14
0
        public void Setup()
        {
            IServiceCollection services = new ServiceCollection();

            NativeInjectorBootStrapper.RegisterServices(services: services);
            serviceProvider = services.BuildServiceProvider();
        }
Beispiel #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))
                                                         options.UseSqlite(Configuration.GetConnectionString("SqLite"))
                                                         );

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(o =>
            {
                o.LoginPath        = new PathString("/login");
                o.AccessDeniedPath = new PathString("/home/access-denied");
            });


            services.AddMvc();
            services.AddAutoMapper();
            AutoMapperConfig.RegisterMappings();

            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));

            // .NET Native DI Abstraction
            NativeInjectorBootStrapper.RegisterServices(services);
        }
Beispiel #16
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            Driver.Initialize("IbC");

            Mapper.Initialize(config =>
            {
                config.AddProfile(new AutoMapperProfile());
            });

            services.AddDbContext <AppDbContext>(options =>
                                                 options.UseSqlServer(
                                                     Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <AppUser>()
            .AddEntityFrameworkStores <AppDbContext>();

            NativeInjectorBootStrapper.RegisterServices(services);
        }
Beispiel #17
0
        private static void RegisterServices(IServiceCollection services)
        {
            services.AddLogging(l => l.AddConsole());

            // Adding dependencies from another layers (isolated from Presentation)
            NativeInjectorBootStrapper.RegisterServices(services);
        }
Beispiel #18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            /* midlewares basicos */
            services.AddWebApiConfig();

            /* midlewares basicos */
            services.AddCorsConfiguration();

            /*Cors básico*/
            services.AddCors();

            /*Configuração de Identity*/
            services.AddIdentityConfiguration(Configuration);

            /*Configuração do Jwt*/
            services.AddJwtConfiguration(Configuration);

            /*autommaper config*/
            services.AddAutoMapperSetup();

            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));
            /*registro das interfaces*/
            NativeInjectorBootStrapper.RegisterServices(services);
        }
Beispiel #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            NativeInjectorBootStrapper.RegisterServices(services: services);

            services.AddDbContext <ECContext>();
            services.AddScoped <IProductServices, ProductServices>();
        }
Beispiel #20
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     NativeInjectorBootStrapper.RegisterServices(services);
     services.AddCors();
     // MediatR
     services.AddMediatR(typeof(Startup));
     services.AddControllersWithViews();
 }
Beispiel #21
0
        private static void RegisterServices(IServiceCollection services)
        {
            // Adding dependencies from another layers (isolated from Presentation)
            NativeInjectorBootStrapper.RegisterServices(services);

            //services.AddSingleton(Mapper.Configuration);
            //services.AddScoped<IMapper>(sp => new Mapper(sp.GetRequiredService<AutoMapper.IConfigurationProvider>(), sp.GetService));
        }
Beispiel #22
0
 public static void AddDependencyInjectionConfiguration(this IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration)
 {
     if (services == null)
     {
         throw new ArgumentNullException(nameof(services));
     }
     NativeInjectorBootStrapper.RegisterServices(services);
 }
Beispiel #23
0
        public void Setup()
        {
            _serverCalc = CreateInMemoryTestServerCalc();

            var service = NativeInjectorBootStrapper.RegisterAll();

            service.AddSingleton(new HttpServiceClient(_serverCalc));
        }
Beispiel #24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => false;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <SegurancaContexto>(options =>
                                                      options.UseSqlServer(
                                                          Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <UsuarioAplicacao>()
            .AddEntityFrameworkStores <SegurancaContexto>();

            services.Configure <IdentityOptions>(options =>
            {
                // Password settings.
                options.Password.RequireDigit           = true;
                options.Password.RequireLowercase       = true;
                options.Password.RequireNonAlphanumeric = true;
                options.Password.RequireUppercase       = true;
                options.Password.RequiredLength         = 6;
                options.Password.RequiredUniqueChars    = 1;

                // Lockout settings.
                options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromMinutes(5);
                options.Lockout.MaxFailedAccessAttempts = 5;
                options.Lockout.AllowedForNewUsers      = true;

                // User settings.
                options.User.AllowedUserNameCharacters =
                    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
                options.User.RequireUniqueEmail = false;
            });

            services.ConfigureApplicationCookie(options =>
            {
                // Cookie settings
                options.Cookie.HttpOnly = true;
                options.ExpireTimeSpan  = TimeSpan.FromMinutes(5);

                options.LoginPath         = "/Identity/Account/Login";
                options.AccessDeniedPath  = "/Identity/Account/AccessDenied";
                options.SlidingExpiration = true;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddAuthorization(options =>
            {
                options.AddPolicy("SomenteBibliotecario", policy => policy.Requirements.Add(new ClaimRequirement("Cargo", "Bibliotecario")));
            });



            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
Beispiel #25
0
        private static void RegisterServices(IServiceCollection services)
        {
            // Adding dependencies from another layers (isolated from Presentation)
            NativeInjectorBootStrapper.RegisterServices(services);

            //FluentValidation
            services.AddTransient <IValidator <MotoristaCadastroPostRequest>, MotoristaCadastroPostValidator>();
            services.AddTransient <IValidator <MotoristaCadastroPutRequest>, MotoristaCadastroPutValidator>();
        }
Beispiel #26
0
 public void ConfigureServices(IServiceCollection services)
 {
     // Context Configuration
     NativeInjectorBootStrapper.AddContextConfiguration(services, GetConnectionString());
     // Api Configuration
     services.AddApiConfiguration();
     // Swagger Configuration
     services.AddSwaggerConfiguration();
 }
Beispiel #27
0
        public static void ConfigureServiceDIs(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            NativeInjectorBootStrapper.RegisterServices(services);
        }
Beispiel #28
0
 protected void ConfigureServices(IServiceCollection services)
 {
     // Context Config
     ConfigureDbContext(services);
     // Dependencies Config
     NativeInjectorBootStrapper.AddApiConfiguration(services);
     // AutoMapper
     services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
 }
Beispiel #29
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddAutoMapper();

            services.AddOptions();

            NativeInjectorBootStrapper.RegisterServices(services, Configuration);
        }
        public static void AddDependencyInjectionSetup(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            NativeInjectorBootStrapper.RegisterServices(services);
        }