-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (37 loc) · 1.08 KB
/
Program.cs
File metadata and controls
44 lines (37 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.Extensions.Configuration;
using Microsoft.FeatureManagement;
//
// Setup configuration
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var featureManager = new FeatureManager(new ConfigurationFeatureDefinitionProvider(configuration))
{
FeatureFilters = new List<IFeatureFilterMetadata> { new AccountIdFilter() }
};
var accounts = new List<string>()
{
"abc",
"adef",
"abcdefghijklmnopqrstuvwxyz"
};
//
// Mimic work items in a task-driven console application
foreach (var account in accounts)
{
const string FeatureName = "Beta";
//
// Check if feature enabled
//
var accountServiceContext = new AccountServiceContext
{
AccountId = account
};
bool enabled = await featureManager.IsEnabledAsync(FeatureName, accountServiceContext);
//
// Output results
Console.WriteLine($"The {FeatureName} feature is {(enabled ? "enabled" : "disabled")} for the '{account}' account.");
}