mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat(onboarding): .NET snippet (#8307)
## About the changes Quick-start for .NET
This commit is contained in:
parent
bf787b6deb
commit
b03686dc3f
@ -8,13 +8,47 @@ dotnet add package Newtonsoft.Json
|
|||||||
2\. Initialize Unleash
|
2\. Initialize Unleash
|
||||||
```csharp
|
```csharp
|
||||||
using 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```csharp
|
||||||
var settings = new UnleashSettings()
|
var settings = new UnleashSettings()
|
||||||
{
|
{
|
||||||
AppName = "unleash-onboarding-dotnet",
|
AppName = "unleash-onboarding-dotnet",
|
||||||
UnleashApi = new Uri("<YOUR_API_URL>"),
|
UnleashApi = new Uri("<YOUR_API_URL>"),
|
||||||
CustomHttpHeaders = new Dictionary<string, string>()
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user