internal static void Go(string[] args)
    {
        var config = GetConfig(args);

        var configured = StrongConfig.Instance(config);

        PrintConfig(config, configured);
    }
Exemplo n.º 2
0
    protected void PrintConfig(StrongConfig config)
    {
        var po = config.Position;
        var cs = config.ConnectionStrings;

        Kv("MsSql", cs.MsSql);
        Kv("PgSql", cs.PgSql);

        Kv("Title", po.Title);
        Kv("Name", po.Name);
    }
    private static void PrintConfig(IConfiguration config, StrongConfig configured)
    {
        var po = configured.Position;

        var section = config.GetSection("ConnectionStrings");

        Kv("MsSql", section.GetValue <string>("MsSql"));
        Kv("PgSql", section.GetValue <string>("PgSql"));

        Kv("ConnectionString", config["ConnectionString"]);
        Kv("Title", po.Title);
        Kv("Name", po.Name);
        Kv("defaultLogLevel", config["Logging:LogLevel:Default"]);
    }
Exemplo n.º 4
0
    public void ConfigureServices(HostBuilderContext host, IServiceCollection services)
    {
        Title("Configure Services");

        var config = host.Configuration;
        var strong = StrongConfig.Instance(config);

        PrintConfig(config);
        PrintConfig(strong);

        services.Configure <PositionOptions>(host.Configuration.GetSection(PositionOptions.SectionName));
        services.AddSingleton <IHostedService, App5Service>();
        // services.AddDbContext<DbPgContext>();



        Title("Finished Startup Pipeline");
    }
    internal static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
    .ConfigureHostConfiguration(config =>
    {
        config
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appSettings.json", optional: true, reloadOnChange: true)
        // .AddEnvironmentVariables(prefix: "DOT_")
        .AddEnvironmentVariables()
        .AddCommandLine(args);
    })
    .ConfigureAppConfiguration((hostContext, config) =>
    {
        var strong = StrongConfig.Instance(config.Build());

        // dnr --environment=Development
        // export DOTNET_ENVIRONMENT="Development"; dnr
        Kv("Is Development", hostContext.HostingEnvironment.IsDevelopment());
        Kv("Environment Name", hostContext.HostingEnvironment.EnvironmentName);

        PrintConfig(config.Build(), strong);
    })
    .ConfigureLogging((hostContext, logging) =>
    {
        // logging.AddConsole();
        // logging.AddDebug();
    })
    .ConfigureServices((hostContext, services) =>
    {
        services.AddOptions();
        // var config = hostContext.Configuration;
        // var strong = StrongConfig.Instance(config);

        // Kv("Is Development", hostContext.HostingEnvironment.IsDevelopment());

        // PrintConfig(config, strong);
        services.AddHostedService <App2Service>();
    });