Ejemplo n.º 1
0
        /// <summary>
        /// Use this if you start identitybase from custom project
        /// </summary>
        /// <typeparam name="TStartup"></typeparam>
        /// <param name="args"></param>
        /// <param name="basePath"></param>
        public static void Run <TStartup>(
            string[] args,
            string basePath)
            where TStartup : class
        {
            IConfiguration config = IdentityBaseWebHost
                                    .LoadConfig <TStartup>(args, basePath);

            // Use in case you changed the example data in ExampleData.cs file
            // Configuration.ExampleDataWriter.Write(config);

            IConfigurationSection configHost = config.GetSection("Host");

            IWebHostBuilder hostBuilder = new WebHostBuilder()
                                          .UseKestrel()
                                          .UseUrls(configHost.GetValue <string>("Urls"))
                                          .UseContentRoot(basePath)
                                          .UseConfiguration(config)
                                          .ConfigureLogging((hostingContext, logging) =>
            {
                logging.AddSerilog(hostingContext.Configuration);
            })
                                          .UseStartup <TStartup>();

            if (configHost.GetValue <bool>("UseIISIntegration"))
            {
                Console.WriteLine("Enabling IIS Integration");
                hostBuilder = hostBuilder.UseIISIntegration();
            }

            hostBuilder.Build().Run();
        }
Ejemplo n.º 2
0
        private static IConfigurationRoot LoadConfig <TStartup>(
            string[] args,
            string basePath)
            where TStartup : class
        {
            bool isDevelopment = IdentityBaseWebHost.IsDevelopment();

            IConfigurationBuilder configBuilder = new ConfigurationBuilder()
                                                  .SetBasePath(basePath)
                                                  .AddJsonFile(
                path: IdentityBaseWebHost.GetConfigFilePath(
                    basePath,
                    isDevelopment
                    ),
                optional: false,
                reloadOnChange: false);

            if (isDevelopment)
            {
                configBuilder.AddUserSecrets <TStartup>();
            }

            configBuilder.AddEnvironmentVariables();

            if (args != null)
            {
                configBuilder.AddCommandLine(args);
            }

            return(configBuilder.Build());
        }
Ejemplo n.º 3
0
 public static void Run <TStartup>(string[] args) where TStartup : class
 {
     IdentityBaseWebHost.Run <TStartup>(
         args,
         Directory.GetCurrentDirectory());
 }