-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add dotnet core sample (#255)
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Unleash\Unleash.csproj"> | ||
<Project>{4cf2127b-8fc8-46fc-8614-3918148463a5}</Project> | ||
<Name>Unleash</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotnetCore", "DotnetCore.csproj", "{CE83946A-DD8A-4D2E-BC85-0B1F6E9A72CE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{CE83946A-DD8A-4D2E-BC85-0B1F6E9A72CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CE83946A-DD8A-4D2E-BC85-0B1F6E9A72CE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CE83946A-DD8A-4D2E-BC85-0B1F6E9A72CE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CE83946A-DD8A-4D2E-BC85-0B1F6E9A72CE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {8085F125-1F8A-4991-BEC4-B7ADD45BA1C0} | ||
EndGlobalSection | ||
EndGlobal |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Unleash; | ||
using Unleash.ClientFactory; | ||
using Unleash.Internal; | ||
|
||
var settings = new UnleashSettings() | ||
{ | ||
AppName = "dotnet-test", | ||
UnleashApi = new Uri("http://localhost:4242/api"), //setup for running against a local unleash instance, feel free to change this | ||
CustomHttpHeaders = new Dictionary<string, string>() | ||
{ | ||
{"Authorization","add a valid client token here" } | ||
}, | ||
SendMetricsInterval = TimeSpan.FromSeconds(1) | ||
}; | ||
|
||
const string TOGGLE_NAME = "test"; | ||
|
||
Console.WriteLine("Starting Unleash SDK"); | ||
|
||
var unleashFactory = new UnleashClientFactory(); | ||
IUnleash unleash = await unleashFactory.CreateClientAsync(settings, synchronousInitialization: true); | ||
|
||
|
||
while (true) | ||
{ | ||
var enabled = unleash.IsEnabled(TOGGLE_NAME); | ||
var variant = unleash.GetVariant(TOGGLE_NAME); | ||
|
||
Console.WriteLine($"Toggle enabled: {enabled}, variant: {System.Text.Json.JsonSerializer.Serialize(variant)}"); | ||
await Task.Delay(1000); | ||
} |