Created
July 15, 2020 12:32
-
-
Save ivarconr/d8a932fc9f37f8f525efbe8bdbc36035 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using System.Collections.Generic; | |
using Unleash; | |
using Unleash.ClientFactory; | |
namespace hello_net | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) | |
{ | |
IUnleash unleash = await DemoAsync(); | |
while(true) { | |
if (unleash.IsEnabled("Demo")) | |
{ | |
Console.WriteLine("ON"); | |
} | |
else | |
{ | |
Console.WriteLine("OFF"); | |
} | |
await Task.Delay(1000); | |
} | |
} | |
public static async Task<IUnleash> DemoAsync() | |
{ | |
var settings = new UnleashSettings() | |
{ | |
AppName = "dot-net-client", | |
Environment = "local", | |
UnleashApi = new Uri("https://app.unleash-hosted.com/demo/api/"), | |
FetchTogglesInterval = TimeSpan.FromSeconds(2), | |
CustomHttpHeaders = new Dictionary<string, string>() | |
{ | |
{"Authorization","56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d" } | |
} | |
}; | |
var unleashFactory = new UnleashClientFactory(); | |
IUnleash unleash = await unleashFactory.Generate(settings, SynchronousInitialization: true); | |
return unleash; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment