mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-09 01:17:06 +02:00
1.4 KiB
1.4 KiB
1. Install the SDK
dotnet add package unleash.client
// If you do not have a json library in your project:
dotnet add package Newtonsoft.Json
2. Initialize Unleash
using Unleash;
using Unleash.ClientFactory;
public class Program
{
public static async Task Main()
{
var settings = new UnleashSettings()
{
AppName = "unleash-onboarding-dotnet",
UnleashApi = new Uri("<YOUR_API_URL>"),
SendMetricsInterval = TimeSpan.FromSeconds(5),
CustomHttpHeaders = new Dictionary<string, string>()
{
{"Authorization","<YOUR_API_TOKEN>"}
}
};
var unleash = new DefaultUnleash(settings);
while (true) {
Console.WriteLine($"Flag is enabled: {unleash.IsEnabled("<YOUR_FLAG>")}");
await Task.Delay(1000);
}
}
}
var settings = new UnleashSettings()
{
AppName = "unleash-onboarding-dotnet",
UnleashApi = new Uri("<YOUR_API_URL>"),
CustomHttpHeaders = new Dictionary<string, string>()
{
{"Authorization",Environment.GetEnvironmentVariable("UNLEASH_API_KEY")}
}
};