/// <summary> /// The static method that calls for the configurations of the dependency injections. /// </summary> /// <param name="services">Interface for specifying contracts for multiple layers of services;</param> /// <param name="configuration">Interface for the configuration builder contract specification.</param> public static void AddDIConfigurations(this IServiceCollection services, IConfiguration configuration) { //Registering dependency injection for contexts. NativeInjector.RegisterContexts(services, configuration); //Registering dependency injection for multiple classes of services. NativeInjector.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <MySQLContext>(options => options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), new MySqlServerVersion(new Version(8, 0, 22)) , builder => { builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null); } ) ); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton(Configuration.GetSection("EmailConfiguration").Get <EmailConfiguration>()); NativeInjector.RegisterServices(services); services.AddSwaggerConfiguration(); services.AddCustomJWTConfiguration(); services.AddAutoMapper(typeof(AutoMapperSetup)); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <AspNetCoreAngularContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("ApsNetCoreAngular")).EnableSensitiveDataLogging()); NativeInjector.RegisterServices(services); services.AddAutoMapper(typeof(AutoMapperSetup)); services.AddSwaggerConfiguration(); var key = Encoding.ASCII.GetBytes(Settings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { NativeInjector.RegistrarServicos(services); services.AddDbContext <SqlContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("ConectString"))); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <AppDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("Template")) ); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton(Configuration.GetSection("EmailConfiguration").Get <EmailConfiguration>()); NativeInjector.RegisterServices(services); services.AddSwaggerConfiguration(); services.AddCustomJWTConfiguration(); services.AddAutoMapper(typeof(AutoMapperSetup)); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAutoMapper(typeof(DomainToViewModelProfile), typeof(ViewModelToDomainProfile)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); NativeInjector.RegisterServices(services); services.AddCors(o => o.AddPolicy("BookStorePolicy", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); services.Configure <MvcOptions>(options => { options.Filters.Add(new CorsAuthorizationFilterFactory("BookStorePolicy")); }); services.AddSwaggerGen(s => { s.SwaggerDoc("v1", new Info { Version = "v1", Title = "Book Store", Description = "Book Store API Swagger surface" }); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <CrudContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); NativeInjector.RegisterServices(services); services.AddControllersWithViews(); }
// 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.AddDefaultPolicy( builder => { builder.WithOrigins() .AllowAnyMethod() .AllowAnyOrigin() .AllowAnyHeader(); }); }); services.AddControllers(); // In production, the Vue files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "appclient/dist"; }); services.AddAutoMapperSetup(); NativeInjector.RegisterServices(services, Configuration); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); var connectionString = Configuration.GetSection("DefaultConnection").Value; services.AddScoped <IUnitOfWork>(x => { var connection = new DbContextOptionsBuilder <ExampleContext>(); //TODO: gerar log para development //if (IsDevelopment) //{ // connection.UseLoggerFactory(LoggerFactory); //} return(new UnitOfWork( new ExampleContext( connection .UseLazyLoadingProxies() .UseSqlServer(connectionString, builder => { //TODO: está obsleto, ver nova opção //builder.UseRowNumberForPaging(); }).Options))); }); NativeInjector.Setup(services); services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => { builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Raízen - CSCustomer", Version = "v1", Description = "API responsável por informações do usuário", Contact = new Microsoft.OpenApi.Models.OpenApiContact { Name = "Raízen CSOnline", } }); }); services.AddApplicationInsightsTelemetry(new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions() { EnableAdaptiveSampling = false }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <TemplateContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("TemplateDB")).EnableSensitiveDataLogging()); NativeInjector.RegisterServices(services); services.AddAutoMapper(typeof(AutoMapperSetup)); services.AddSwaggerConfiguration(); services.AddControllers(); }
public static void AddDependencyInjection(this IServiceCollection services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } NativeInjector.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddControllers(); // Carrega configuração de Injeção de Dependência NativeInjector.RegisterServices(services); // Carrega as configurações do Swagger criado em CrossCutting services.AddSwaggerConfiguration(); }
// 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("CorsPolicy", builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()) ); services.AddControllers(); services.AddDbContext <DataContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("BankAccountsDB")).EnableSensitiveDataLogging()); NativeInjector.RegisterServices(services); services.AddAutoMapper(typeof(AutoMapperSetup)); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy(defaultPolicy, builder => { builder.AllowAnyHeader() .AllowAnyMethod() .AllowAnyOrigin(); }); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <ExampleContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("Examples.Charge.Infra.Data.Configuration")); }); NativeInjector.Setup(services); services.AddAutoMapper(); services.AddSwaggerGen(options => { options.CustomSchemaIds(x => x.FullName); options.CustomOperationIds(e => { return($"{e.ActionDescriptor.RouteValues["controller"]}_{e.HttpMethod}{e.ActionDescriptor.Parameters?.Select(a => a.Name).ToString()}"); }); options.DescribeAllEnumsAsStrings(); options.SwaggerDoc("v1", new Info { Version = "v1", Title = "Example Api", Description = "Example Charge Api.", TermsOfService = "None", Contact = new Contact { Name = "Example", Email = "*****@*****.**" } }); var xmlWebApiFile = Path.Combine(AppContext.BaseDirectory, $"PGC.Api.xml"); if (File.Exists(xmlWebApiFile)) { options.IncludeXmlComments(xmlWebApiFile); } }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <LogRecoveryContext>(option => option.UseNpgsql(Configuration.GetConnectionString("LogRecoveryConnection")).EnableSensitiveDataLogging()); NativeInjector.RegisterSevices(services); services.AddAutoMapper(typeof(AutoMapperSetup)); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
/// <summary> /// The method for running the database's initial data seed. /// </summary> /// <param name="builder">Interface that allows a configuration of the application's request pipeline.</param> /// <returns>The <see cref="IApplicationBuilder"/> after configuring migrations.</returns> public static IApplicationBuilder SeedDatabase(this IApplicationBuilder builder) { try { //Seeding the databases. NativeInjector.SeedDatabases(builder); return(builder); } catch { throw; } }
/// <summary> /// The method for running contexts' migrations. /// </summary> /// <param name="builder">Interface that allows a configuration of the application's request pipeline.</param> /// <returns>The <see cref="IApplicationBuilder"/> after configuring migrations.</returns> public static IApplicationBuilder MigrateContexts(this IApplicationBuilder builder) { try { //Migrating the databases. NativeInjector.MigrateContexts(builder); return(builder); } catch { throw; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <Template_1Context>(opt => opt.UseSqlServer(Configuration.GetConnectionString("Template_1DB")).EnableSensitiveDataLogging()); NativeInjector.RegisterServices(services); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// 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("AllowSpecificOrigin", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); Mapper.Initialize(x => x.ConfigureApplicationProfiles()); NativeInjector.RegisterServices(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// 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.AddAutoMapper(); NativeInjector.RegisterServices(services); RegisterMappings.Register(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public void ConfigureServices(IServiceCollection services) { services.AddEntityFrameworkSqlServer() .AddDbContext <ScheduleMeetingsContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddTransient <IConfigureOptions <SwaggerGenOptions>, ConfigureSwaggerOptions>(); services.AddSwaggerGeneration(); services.AddApiVersioningAndExplorer(); services.AddCors(); services.AddSwaggerGen(c => c.EnableAnnotations()); services.AddHealthChecks(); services.ConfigureFluentValidation(); services.AddMvc().AddNewtonsoftJson(); NativeInjector.RegisterServices(services); }
public static void Main(string[] args) { // create service collection var serviceCollection = new ServiceCollection(); NativeInjector.ConfigureServices(serviceCollection); // add app serviceCollection.AddTransient <App>(); // create service provider var serviceProvider = serviceCollection.BuildServiceProvider(); // run app serviceProvider.GetService <App>().Run(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <ApplicationContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")).EnableSensitiveDataLogging()); // Carrega configuração de Injeção de Dependência NativeInjector.RegisterServices(services); // Carrega as configuração do Automapper. Verificar a Classe de serviço em Application.Services e applicar o AutoMap services.AddAutoMapper(typeof(AutoMapperSetup)); // Carrega as configurações do Swagger criado em CrossCutting services.AddSwaggerConfiguration(); // Configurações de autenticação var key = Encoding.ASCII.GetBytes(Settings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // onde vai pegar a conexão Strings e qual o DB que eu tenho que inserir as informações nele services.AddControllersWithViews(); services.AddDbContext <TemplateContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("TemplateDB")).EnableSensitiveDataLogging()); NativeInjector.RegisterServices(services);//chamando o metodo services.AddAutoMapper(typeof(AutoMapperSetup)); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
static void Main(string[] args) { //setup our DI NativeInjector.RegisterServices(Services, Configuration); // Regular: 16Mar2020(mon), 17Mar2020(tues), 18Mar2020(wed) Console.WriteLine("Informe a busca"); string search = Console.ReadLine(); string typeClient = search.Split(':')[0]; var dates = search.Split(':')[1].Split(','); List <DateTime> formatedDates = new List <DateTime>(); foreach (var date in dates) { formatedDates.Add(ParseinputDate(date)); } var bar = serviceProvider.GetService <IHotelService>(); }
// 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.RespectBrowserAcceptHeader = true; options.OutputFormatters.Clear(); options.OutputFormatters.Add(new JsonOutputFormatter(new JsonSerializerSettings(), ArrayPool <char> .Shared)); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "DDDSample API", Version = "v1" }); c.IncludeXmlComments(Path.Combine(HostingEnvironment.ContentRootPath, "wwwroot", HostingEnvironment.ApplicationName + ".xml")); }); services.RegisterAutoMapper(); services.AddMediatR(typeof(HouseEventHandler)); NativeInjector.RegisterServies(services, Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); string connectionString = Configuration.GetConnectionString("Default"); services.AddDbContext <EntityContext>(options => options.UseMySQL(connectionString) ); NativeInjector.Registros(services); var configuracoesSwagger = new Microsoft.OpenApi.Models.OpenApiInfo { Title = "TodoAPI", Version = "v1" }; services.AddSwaggerGen(c => { c.SwaggerDoc("v1", configuracoesSwagger); }); }
private static void RegisterServices(IServiceCollection services) { services.AddSingleton(typeof(CacheSegments)); NativeInjector.RegisterServices(services); }
public static void AddDIConfiguration(this IServiceCollection services) { NativeInjector.RegisterServices(services); }
/// <summary> /// The static method that calls for the configurations of the external data in static files. /// </summary> /// <param name="services">Interface for specifying contracts for multiple layers of services;</param> /// <param name="configuration">Interface for the configuration builder contract specification.</param> public static void AddExternalDataConfigurations(this IServiceCollection services, IConfiguration configuration) { //Registering external data configurations. NativeInjector.RegisterExternalConfigurations(services, configuration); }