From b03686dc3f65a3aa4232aee7e03de2171108868a Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Tue, 1 Oct 2024 13:20:49 +0200 Subject: [PATCH] feat(onboarding): .NET snippet (#8307) ## About the changes Quick-start for .NET --- .../onboarding/dialog/snippets/dotnet.md | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/onboarding/dialog/snippets/dotnet.md b/frontend/src/component/onboarding/dialog/snippets/dotnet.md index 9f965ba725e6..c0827a26efb0 100644 --- a/frontend/src/component/onboarding/dialog/snippets/dotnet.md +++ b/frontend/src/component/onboarding/dialog/snippets/dotnet.md @@ -8,13 +8,47 @@ dotnet add package Newtonsoft.Json 2\. Initialize Unleash ```csharp using Unleash; +using Unleash.ClientFactory; + +public class Program +{ + public static async Task Main() + { + var settings = new UnleashSettings() + { + AppName = "unleash-onboarding-dotnet", + UnleashApi = new Uri(""), + SendMetricsInterval = TimeSpan.FromSeconds(5), + CustomHttpHeaders = new Dictionary() + { + {"Authorization",""} + } + }; + + var unleash = new DefaultUnleash(settings); + + while (true) { + Console.WriteLine($"Flag is enabled: {unleash.IsEnabled("")}"); + await Task.Delay(1000); + } + } +} + +``` + +--- +```csharp var settings = new UnleashSettings() { AppName = "unleash-onboarding-dotnet", UnleashApi = new Uri(""), CustomHttpHeaders = new Dictionary() { - {"Authorization","" } + {"Authorization",Environment.GetEnvironmentVariable("UNLEASH_API_KEY")} } }; ``` + +--- +- [SDK repository with documentation](https://github.com/Unleash/unleash-client-dotnet) +- [.NET/C# SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/Csharp)