-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLDClient.cs
More file actions
49 lines (43 loc) · 1.05 KB
/
LDClient.cs
File metadata and controls
49 lines (43 loc) · 1.05 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Server;
using LaunchDarkly.Sdk.Server.Interfaces;
using LaunchDarkly.Sdk.Server.Subsystems;
using DotEnv.Core;
public sealed class LDClient
{
private static readonly object myLock = new object();
private static LDClient? instance = null;
private LdClient client;
private LDClient()
{
new EnvLoader().Load(); // Loads the .env file
var reader = new EnvReader();
string sdkKey = reader["LD_SDK_KEY"];
client = new LdClient(sdkKey);
client.FlagTracker.FlagChanged += (s, e) =>
{
Console.WriteLine("Here: \"{0}\"!", e.Key);
};
}
private static LDClient Instance
{
get
{
lock (myLock)
{
if (instance == null)
{
instance = new LDClient();
}
return instance;
}
}
}
public static LdClient Client
{
get
{
return Instance.client;
}
}
}