Exemplo n.º 1
0
        public void Configuration_Bind_Parameterless_Test()
        {
            IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("app.json").Build();

            SimpleAppOptions simpleAppOptions = new SimpleAppOptions();

            configuration.GetSection("SimpleAppOptions").Bind(simpleAppOptions);
        }
Exemplo n.º 2
0
        public void Options_Parameterless_Test()
        {
            IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("app.json").Build();

            ServiceCollection services = new ServiceCollection();

            services.Configure <SimpleAppOptions>(configuration.GetSection("SimpleAppOptions"));

            IServiceProvider serviceProvider = services.BuildServiceProvider();

            IOptions <SimpleAppOptions>?options = serviceProvider.GetRequiredService <IOptions <SimpleAppOptions> >();

            SimpleAppOptions simpleAppOptions = options.Value;
        }