{ "Setting": { "Name" : "FooBar", "Age" : 20 } }
Startup.cs
public void ConfigureServices(IServiceCollection services) { services.Configure(Configuration.GetSection("Hogehoge")); }
Models/Hogehoge.cs
public class Hogehoge { public string Name { get; set; } public int Age { get; set; } }
Controllers/HomeController.cs
public HomeController(IOptionsoption){ //option.Value.Name //option.Value.Age }
0 件のコメント:
コメントを投稿