public static void AddDependencyInjectionCustom(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment environment) { DependencyInjector.RegisterServices(services, environment); string connection = configuration.GetConnectionString("BloggingDatabase"); DependencyInjector.AddDbContext <GtrEntities>(connection); }
static public void AddDependencyInjectionConfiguration(this IServiceCollection services, IConfiguration Configuration) { DependencyInjector.RegisterServices(services); DependencyInjector.AddDbContext <DatabaseContext>(Configuration.GetConnectionString(nameof(DataBaseContext))); // services.Configure<IMongoConnectionString>( //Configuration.GetSection(nameof(MongoConnectionString))); // services.AddSingleton<IMongoConnectionString>(sp => // sp.GetRequiredService<IOptions<MongoConnectionString>>().Value); }
/// <summary> /// Method to configure services. /// </summary> /// <param name="services">Service Collection.</param> public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest); DependencyInjector.RegisterServices(services); DependencyInjector.AddAutoMapper(); DependencyInjector.AddDbContext(this.Configuration); Log.Logger = new LoggerConfiguration().MinimumLevel.Information() .WriteTo.RollingFile("log-{Date}.txt", LogEventLevel.Information) .WriteTo.Seq(this.Configuration["SeqUrl"]) .CreateLogger(); ILoggerFactory loggerFactory = new LoggerFactory(); loggerFactory.AddSerilog(); services.AddSingleton(loggerFactory); services.AddDiscoveryClient(this.Configuration); var mvcBuilder = services.AddMvc(); mvcBuilder.AddMvcOptions(p => p.Filters.Add(new CustomActionFilterAttribute(Log.Logger))); mvcBuilder.AddMvcOptions(p => p.Filters.Add(new CustomExceptionFilterAttribute(Log.Logger))); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Version = "v1", Title = "Api Users", Description = "Api para información de usuarios", Contact = new Microsoft.OpenApi.Models.OpenApiContact { Name = "Axity", Url = new System.Uri(AXITYURL), }, }); }); services.Configure <GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Fastest); services.AddResponseCompression(); }
public static void AddDependencyInjectionCustom(this IServiceCollection services, IConfiguration configuration) { DependencyInjector.RegisterServices(services); DependencyInjector.AddDbContext <DatabaseContext>(configuration.GetConnectionString(nameof(DatabaseContext))); DependencyInjector.GetService <DatabaseContext>().Seed(); }
public static void AddDependencyInjectionCustom(this IServiceCollection services, IConfiguration configuration) { DependencyInjector.RegisterServices(services); DependencyInjector.AddDbContext <NorthwindContext>(configuration.GetConnectionString(nameof(NorthwindContext))); }
public static void AddDependencyInjectionCustom(this IServiceCollection services, IConfiguration configuration) { DependencyInjector.RegisterServices(services); DependencyInjector.AddDbContext <DesignAutomatorContext>(configuration.GetConnectionString("DefaultConnection")); }