It would be useful when the use_config function of the application computation expression provides access to the Microsoft.Extensions.Configuration.IConfiguration object or the HttpContext itself.
I wanted to read the application settings from ASP.NET Core and put it in a Settings record, but my solution is pretty ugly.
let configureContextAccessor (services: IServiceCollection) =
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>()
let setupConfiguration () =
let ctx = HttpContextAccessor()
let config = ctx.HttpContext.GetService<IConfiguration>()
{ SampleSetting = config.["sampleSetting"] }
let app = application {
...
service_config configureContextAccessor
use_config setupConfiguration
...
}
I couldn't find a nicer way to access the IConfiguration object.
Yes, currently accessing IConfiguration on the application level is a problem. I think I'd be open to changing use_config to take IConfiguration -> 'T as a parameter, instead of just 'T
It would be useful when the
use_config
function of theapplication
computation expression provides access to theMicrosoft.Extensions.Configuration.IConfiguration
object or theHttpContext
itself.I wanted to read the application settings from ASP.NET Core and put it in a Settings record, but my solution is pretty ugly.
I couldn't find a nicer way to access the
IConfiguration
object.