コード例 #1
0
 public ShopController(IConfiguration configuration, IFeatureFlag feature, IMemoryCache cache, IEventBus eventBus)
 {
     _configuration = configuration;
     _feature       = feature;
     _cache         = cache;
     _eventBus      = eventBus;
 }
コード例 #2
0
ファイル: FeatureFlagTests.cs プロジェクト: shoshiiran/cscore
        public async Task ExampleUsage1()
        {
            // Get your key from https://console.developers.google.com/apis/credentials
            var apiKey = "AIzaSyCtcFQMgRIUHhSuXggm4BtXT4eZvUrBWN0";
            // https://docs.google.com/spreadsheets/d/1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM contains the sheetId:
            var sheetId           = "1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM";
            var sheetName         = "MySheet1"; // Has to match the sheet name
            var googleSheetsStore = new GoogleSheetsKeyValueStore(new InMemoryKeyValueStore(), apiKey, sheetId, sheetName);
            var testStore         = new FeatureFlagStore(new InMemoryKeyValueStore(), googleSheetsStore);

            IoC.inject.SetSingleton <FeatureFlagManager <FeatureFlag> >(new FeatureFlagManager <FeatureFlag>(testStore));

            // Open https://docs.google.com/spreadsheets/d/1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM for these:
            Assert.False(await FeatureFlag.IsEnabled("MyFlag1"));
            Assert.True(await FeatureFlag.IsEnabled("MyFlag2"));

            var          key3  = "MyFlag3";
            IFeatureFlag flag3 = await FeatureFlagManager <FeatureFlag> .instance.GetFeatureFlag(key3);

            Assert.Equal(40, flag3.rolloutPercentage); // Rollout of feature 3 is at 40%

            // The local random value that was chosen determines if the flag is enabled or not:
            if (flag3.localState.randomPercentage <= flag3.rolloutPercentage)
            {
                Assert.True(await FeatureFlag.IsEnabled(key3));
            }
            else
            {
                Assert.False(await FeatureFlag.IsEnabled(key3));
            }
        }
コード例 #3
0
 public FeatureFlagController(IFeatureFlag featureFlag)
 {
     _featureFlag = featureFlag;
 }
コード例 #4
0
 private bool LastCachedIsFeatureUnlocked(IFeatureFlag featureFlag)
 {
     return(featureFlag.requiredXp <= GetLastCachedXp());
 }
コード例 #5
0
 public static bool IsActive(this IFeatureFlag feature, FeatureContext context)
 {
     return(feature.GetState(context) == FeatureFlagState.Active);
 }
コード例 #6
0
 public static bool IsActive(this IFeatureFlag feature)
 {
     return(feature.GetState(null) == FeatureFlagState.Active);
 }
コード例 #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="roles">Roles to check.</param>
 /// <param name="featureFlags">Optional Feature Flag service.</param>
 public RoleRequirementFilter(string[] roles, IFeatureFlag featureFlags = null)
 {
     _roles        = roles;
     _featureFlags = featureFlags;
 }
コード例 #8
0
 public ShopControllerV1(IConfiguration configuration, IFeatureFlag feature)
 {
     _configuration = configuration;
     _feature       = feature;
 }