Exemple #1
0
 public static IWebHost BuildWebHost(string[] args)
 {
     return(new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .ConfigureAppConfiguration((hostingContext, config) =>
     {
         var env = hostingContext.HostingEnvironment;
         ConfigurationSettings.Initial(hostingContext, config, args, env.ContentRootPath);
     })
            .ConfigureLogging((hostingContext, logging) =>
     {
         logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
         //logging.AddConsole();
         //logging.AddDebug();
     })
            .UseIISIntegration()
            .UseDefaultServiceProvider((context, options) =>
     {
         options.ValidateScopes = false;//context.HostingEnvironment.IsDevelopment();
     })
            .ConfigureServices(services =>
     {
         services.AddTransient <IConfigureOptions <KestrelServerOptions>, KestrelServerOptionsSetup>();
     })
            .UseStartup <Startup>()
            .UseUrls("http://localhost:5003")
            .Build());
 }
Exemple #2
0
        public AppDbContext CreateDbContext(string[] args)
        {
            var config  = ConfigurationSettings.Initial(null, null, Directory.GetCurrentDirectory()).Build();
            var builder = new DbContextOptionsBuilder <AppDbContext>();

            builder.UseMySQL("server=localhost;database=unitofworkdb;user=root;password=Cosmicworks123");
            return(new AppDbContext(builder.Options));
        }
Exemple #3
0
        public AppUserDbContext CreateDbContext(string[] args)
        {
            var config = ConfigurationSettings.Initial(Directory.GetCurrentDirectory()).Build();

            var builder = new DbContextOptionsBuilder <AppUserDbContext>();

            builder.UseMySQL(config["Database:UserConnectionString"]);
            return(new AppUserDbContext(builder.Options));
        }
Exemple #4
0
        public static IWebHost BuildWebHost(string[] args)
        {
            return(new WebHostBuilder()
                   .UseKestrel()
                   .UseContentRoot(Directory.GetCurrentDirectory())
                   .ConfigureAppConfiguration((hostingContext, config) =>
            {
                var env = hostingContext.HostingEnvironment;
                ConfigurationSettings.Initial(hostingContext, config, args, env.ContentRootPath);

                /*
                 * var env = hostingContext.HostingEnvironment;
                 * var settingPath = Path.GetFullPath(Path.Combine(@"../NT_Common/globalSettings.json"));
                 *
                 * config.AddJsonFile(path: settingPath, optional: true, reloadOnChange: true);
                 * config.SetBasePath(env.ContentRootPath).AddJsonFile(path:"appsettings.json", optional: true, reloadOnChange: true).AddJsonFile(path: $"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
                 *
                 * if (env.IsDevelopment())
                 * {
                 *  var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName));
                 *  if (appAssembly != null)
                 *  {
                 *      config.AddUserSecrets(appAssembly, optional: true);
                 *  }
                 * }
                 * config.AddEnvironmentVariables();
                 *
                 * if (args != null)
                 * {
                 *  config.AddCommandLine(args);
                 * }
                 */
            })
                   .ConfigureLogging((hostingContext, logging) =>
            {
                logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
                //logging.AddConsole();
                //logging.AddDebug();
            })
                   .UseIISIntegration()
                   .UseDefaultServiceProvider((context, options) =>
            {
                options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
            })
                   .ConfigureServices(services =>
            {
                services.AddTransient <IConfigureOptions <KestrelServerOptions>, KestrelServerOptionsSetup>();
            })
                   .UseStartup <Startup>()
                   //.UseUrls("http://*:5000")
                   .Build());
        }
Exemple #5
0
 private void InitialConfiguration()
 {
     _configuration = ConfigurationSettings.Initial(Directory.GetCurrentDirectory()).Build();
 }