Beispiel #1
0
        public async Task <FeatureFlag> GetFeatureFlag(string featureId)
        {
            FeatureFlag flag = await store.Get(featureId, null);

            if (flag != null && flag.localState.randomPercentage == 0)
            {
                // if the server decided its a staged rollout no rnd % generated yet so do it:
                flag.localState.randomPercentage = new Random().Next(1, 100);
                await store.Set(flag.id, flag); // save in local store
            }
            return(flag);
        }
Beispiel #2
0
        public async Task <IEnumerable <News> > GetAllNews()
        {
            IEnumerable <News> allNews = await newsStore.GetAll();

            allNews = await allNews.MapAsync(async news => { // Include localData from the cache:
                news.localData = await localCache.Get(news.key, null);
                return(news);
            });

            allNews = allNews.OrderByDescending(x => x.GetDate(true));
            return(allNews);
        }
        public static async Task <IEnumerable <UsageRule> > GetRulesInitialized(this KeyValueStoreTypeAdapter <UsageRule> self, LocalAnalytics analytics)
        {
            var rules = await self.GetAll();

            foreach (var rule in rules)
            {
                if (!rule.concatRuleIds.IsNullOrEmpty())
                {
                    rule.andRules = new List <UsageRule>();
                    foreach (var id in rule.concatRuleIds)
                    {
                        rule.andRules.Add(await self.Get(id, null));
                    }
                }
                if (rule.isTrue == null)
                {
                    rule.SetupUsing(analytics);
                }
            }
            return(rules);
        }
Beispiel #4
0
 public async Task <T> GetFeatureFlag(string featureId)
 {
     return(await ReturnInitializedFlag(await featureFlagStore.Get(featureId, default(T))));
 }