Skip to content

Commit

Permalink
feat(onboarding): dotnet snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Sep 30, 2024
1 parent a4ea46d commit df84292
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 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,48 @@ 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(1),
CustomHttpHeaders = new Dictionary<string, string>()
{
{"Authorization",Environment.GetEnvironmentVariable("<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>"),
SendMetricsInterval = TimeSpan.FromSeconds(1),
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 df84292

Please sign in to comment.