// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            DevConnectionString = ConfigurationRoot.GetConnectionString("DemoDB");

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Beispiel #2
0
        private ApplicationDbContext getNewDBContext()
        {
            var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionBuilder.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            ApplicationDbContext context = new ApplicationDbContext(optionBuilder.Options);

            return(context);
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddDbContext <ContextBco>(

                option => option.UseSqlServer(ConfigurationRoot.GetConnectionString("BancoAula"))
                );

            services.AddSingleton <IConfiguration>(ConfigurationRoot);

            services.AddScoped(typeof(ContextBco));

            //var cont =  (AppzContext)services.BuildServiceProvider().GetService(typeof(AppzContext));

            // services.AddScoped<IPessoaRepository,PessoaRepository>();

            //new PessoaRepository(services.BuildServiceProvider().GetServices<AppzContext>())
        }
Beispiel #4
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });
            services.AddSingleton(AutoMapperConfig.Initialize());
            services.AddDbContext <EF.AppContext>(options => {
                options.UseSqlServer(ConfigurationRoot.GetConnectionString("SqlServer"));
            });
            services.AddMemoryCache();
            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(Encoding.ASCII.GetBytes(ConfigurationRoot["jwt:key"])),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            var builder = new ContainerBuilder();

            builder.Populate(services);

            builder.RegisterModule <CommandModule>();
            builder.RegisterModule <QueryModule>();
            builder.RegisterModule(new SettingsModule(ConfigurationRoot));
            builder.RegisterModule <ServiceModule>();
            builder.RegisterModule <RepositoryModule>();

            ApplicationContainer = builder.Build();
            return(new AutofacServiceProvider(ApplicationContainer));
        }
Beispiel #5
0
        public static IContainer CompositionRoot()
        {
            LoadAppSettings();

            var builder = new ContainerBuilder();

            builder.RegisterType <Application>();

            /*
             * var dumpToFilePath = ConfigurationRoot.GetSection("ExtractionDetails")["ExtractionFilePath"];
             * builder.RegisterType<JsonRepository>()
             *  .As<IRepository>()
             *  .WithParameter(new NamedParameter("filePath", dumpToFilePath));*/
            var connectionString = ConfigurationRoot.GetConnectionString("astroEventsDb");

            builder.RegisterType <SqliteRepository>()
            .As <IRepository>()
            .WithParameter(new NamedParameter("connectionString", connectionString));

            var astroWikiUrl = ConfigurationRoot.GetSection("ExtractionDetails")["AstroWikiAPIUrl"];

            builder.RegisterType <ScrappyService>()
            .As <IScrapingService>()
            .WithParameter(new NamedParameter("astroWikiUrl", astroWikiUrl));

            var loggerFactory = LoggerFactory.Create(b =>
            {
                b.AddFilter("Microsoft", LogLevel.Warning)
                .AddFilter("System", LogLevel.Warning)
                .AddFilter("WikiScraper.Program", LogLevel.Debug)
                .AddConsole();
            });
            var logger = loggerFactory.CreateLogger <Program>();

            builder.RegisterInstance(logger).As <ILogger>();

            builder.RegisterType <AstroParser>().As <IParser>();

            return(builder.Build());
        }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddDbContext <TMovieDbContext>(options =>
                                                    options.UseSqlServer(ConfigurationRoot.GetConnectionString("TMConnection"), opt => opt.UseRowNumberForPaging()));


            services.AddMvc();

            // Add application services.
            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddTransient <ISmsSender, AuthMessageSender>();

            var builder = new ContainerBuilder();

            builder.Populate(services);


            //~~AppConfig.Init(services);
            ConfigureModules(services);
            //~~AppConfig.ConfigServiceProvider(services.BuildServiceProvider());
        }
Beispiel #7
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.UseMySQL(ConfigurationRoot.GetConnectionString("ProdConnection"));
 }
Beispiel #8
0
 public DapperTest()
 {
     _connectionString = ConfigurationRoot.GetConnectionString("test");
 }
        public string GetConnectionString(string name)
        {
            string connection = ConfigurationRoot.GetConnectionString(name);

            return(connection);
        }