Created
January 20, 2021 23:52
-
-
Save ninjarobot/e71643ab4889cf9c5b133d62bba4647f to your computer and use it in GitHub Desktop.
Load a configuration source from a JSON string in F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Microsoft.Extensions.Configuration | |
/// Builds a configuration source from raw JSON. | |
let configSourceFromJson (json:string) : IConfigurationSource = | |
{ new IConfigurationSource with | |
member this.Build (builder:IConfigurationBuilder) = | |
{ new ConfigurationProvider() with | |
member this.Load() = | |
this.Data <- Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string,string>> json | |
} :> IConfigurationProvider | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment