1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-04 01:18:20 +02:00
unleash.unleash/frontend/src/component/onboarding/dialog/snippets/dotnet.md
Jaanus Sellin 8f4454039a
feat: start capturing onboarded status also from register endpoint (#8386)
1. Remove all customer intervals
2. Start capturing onboarded status also from register endpoint
2024-10-08 12:40:33 +03:00

1.3 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>"),
            CustomHttpHeaders = new Dictionary<string, string>()
            {
                {"Authorization","<YOUR_API_TOKEN>"} // in production use environment variable
            }
        };

        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")}
    }
};