Search code examples
inversion-of-controlioc-containergrace-ioc

How to use configure method of Grace IOC for Application Settings


I am using Grace and I want to configure it to track my settings in appsettins.json file. I can configure that with default container of ASP.NET Core like the following:

services.Configure<DatabaseConnectionSettings>(this.Configuration.GetSection("Database:Connection"));

and later use the IOptions<DatabaseConnectionSettings> or for reloading capability IOptionsSnapshot<DatabaseConnectionSettings> to get the strong-typed values from the container. How can I achieve this when using Grace? and will it support the reload capability of settings when the underlying data changed?


Solution

  • You can continue configuring your application the exact same way. What ever is registered in the service collection will be registered automatically in Grace. I just created an sample app to test that