-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathSettingProvider.fs
More file actions
32 lines (27 loc) · 1.07 KB
/
SettingProvider.fs
File metadata and controls
32 lines (27 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/// Copyright (c) Microsoft Corporation.
module Microsoft.FSharpLu.Azure.SettingProvider
open Microsoft.FSharpLu.Configuration
open System.Configuration
type SettingProvider =
{
getConnectionString : string -> string
getSetting : string -> string
tryGetSetting : string -> Option<string>
}
/// Retrieve connection string from config file (app.config or web.config)
let ConfigFileProvider =
{
getConnectionString = fun key ->
match ConfigurationManager.ConnectionStrings.Item(key) with
| v when v <> null && v.ConnectionString <> null ->
v.ConnectionString
| _ ->
match getConfigValue key with
| null -> invalidOp "Connection string missing from app.config/web.config configuration"
| v -> v
getSetting = fun settingKey ->
match getConfigValue settingKey with
| null -> invalidOp "Setting missing from app.config/web.config configuration"
| v -> v
tryGetSetting = tryGetConfigValue
}