Skip to content

Commit

Permalink
feat(onboarding): .NET snippet (#8307)
Browse files Browse the repository at this point in the history
## About the changes
Quick-start for .NET
  • Loading branch information
Tymek authored Oct 1, 2024
1 parent bf787b6 commit b03686d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion frontend/src/component/onboarding/dialog/snippets/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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("<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);
}
}
}

```

---
```csharp
var settings = new UnleashSettings()
{
AppName = "unleash-onboarding-dotnet",
UnleashApi = new Uri("<YOUR_API_URL>"),
CustomHttpHeaders = new Dictionary<string, string>()
{
{"Authorization","<YOUR_API_TOKEN>" }
{"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)

0 comments on commit b03686d

Please sign in to comment.