Esempio n. 1
0
        /// <summary>
        /// Gets Map of all FeatureFlags and associated experiment map inside it
        /// </summary>
        /// <param name="projectConfig">The project config</param>
        /// <param name="experimentsMapById">Dictionary of experiment Id as key and value as experiment object</param>
        /// <returns>Dictionary | Dictionary of FeatureFlag key and value as OptimizelyFeature object</returns>
        private IDictionary <string, OptimizelyFeature> GetFeaturesMap(ProjectConfig projectConfig, IDictionary <string, OptimizelyExperiment> experimentsMapById)
        {
            var FeaturesMap = new Dictionary <string, OptimizelyFeature>();

            foreach (var featureFlag in projectConfig.FeatureFlags)
            {
                var experimentRules = featureFlag.ExperimentIds.Select(experimentId => experimentsMapById[experimentId]).ToList();

                var featureVariableMap = featureFlag.Variables.Select(v => (OptimizelyVariable)v).ToDictionary(k => k.Key, v => v) ?? new Dictionary <string, OptimizelyVariable>();

                var featureExperimentMap = experimentRules.ToDictionary(experiment => experiment.Key, experiment => experiment);
                var rollout       = projectConfig.GetRolloutFromId(featureFlag.RolloutId);
                var deliveryRules = GetDeliveryRules(featureFlag.Id, rollout.Experiments, projectConfig);

                var optimizelyFeature = new OptimizelyFeature(featureFlag.Id,
                                                              featureFlag.Key,
                                                              experimentRules,
                                                              deliveryRules,
                                                              featureExperimentMap,
                                                              featureVariableMap);

                FeaturesMap.Add(featureFlag.Key, optimizelyFeature);
            }

            return(FeaturesMap);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets Map of all FeatureFlags and associated experiment map inside it
        /// </summary>
        /// <param name="projectConfig">The project config</param>
        /// <param name="experimentsMap">Dictionary of experiment key and value as experiment object</param>
        /// <returns>Dictionary | Dictionary of FeatureFlag key and value as OptimizelyFeature object</returns>
        private IDictionary <string, OptimizelyFeature> GetFeaturesMap(ProjectConfig projectConfig, IDictionary <string, OptimizelyExperiment> experimentsMap)
        {
            var FeaturesMap = new Dictionary <string, OptimizelyFeature>();

            foreach (var featureFlag in projectConfig.FeatureFlags)
            {
                var featureExperimentMap = experimentsMap.Where(expMap => featureFlag.ExperimentIds.Contains(expMap.Value.Id)).ToDictionary(k => k.Key, v => v.Value);

                var featureVariableMap = featureFlag.Variables.Select(v => (OptimizelyVariable)v).ToDictionary(k => k.Key, v => v) ?? new Dictionary <string, OptimizelyVariable>();

                var optimizelyFeature = new OptimizelyFeature(featureFlag.Id, featureFlag.Key, featureExperimentMap, featureVariableMap);

                FeaturesMap.Add(featureFlag.Key, optimizelyFeature);
            }

            return(FeaturesMap);
        }