Ejemplo n.º 1
0
        /// <summary>
        /// Gets Map of all experiments except rollouts
        /// </summary>
        /// <param name="projectConfig">The project config</param>
        /// <returns>Dictionary | Dictionary of experiment key and value as experiment object</returns>
        private IDictionary <string, OptimizelyExperiment> GetExperimentsMap(ProjectConfig projectConfig)
        {
            var experimentsMap       = new Dictionary <string, OptimizelyExperiment>();
            var featureVariableIdMap = GetVariableIdMap(projectConfig);
            var experiments          = projectConfig?.Experiments?.ToList();

            experiments = projectConfig?.Groups?.SelectMany(g => g.Experiments).Concat(experiments)?.ToList();

            foreach (Experiment experiment in experiments)
            {
                var variationsMap = new Dictionary <string, OptimizelyVariation>();
                foreach (Variation variation in experiment.Variations)
                {
                    var variablesMap = MergeFeatureVariables(projectConfig,
                                                             featureVariableIdMap,
                                                             experiment.Id,
                                                             variation);

                    var optimizelyVariation = new OptimizelyVariation(variation.Id,
                                                                      variation.Key,
                                                                      variation.FeatureEnabled,
                                                                      variablesMap);

                    variationsMap.Add(variation.Key, optimizelyVariation);
                }
                var optimizelyExperiment = new OptimizelyExperiment(experiment.Id,
                                                                    experiment.Key,
                                                                    variationsMap);

                experimentsMap.Add(experiment.Key, optimizelyExperiment);
            }

            return(experimentsMap);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets Map of all experiment variations and variables including rollouts
        /// </summary>
        /// <param name="variations">variations</param>
        /// <param name="featureVariableIdMap">The map of feature variables and id</param>
        /// <param name="featureId">feature Id of the feature</param>
        /// <returns>Dictionary | Dictionary of experiment key and value as experiment object</returns>
        private IDictionary <string, OptimizelyVariation> GetVariationsMap(IEnumerable <Variation> variations,
                                                                           IDictionary <string, FeatureVariable> featureVariableIdMap,
                                                                           string featureId)
        {
            var variationsMap = new Dictionary <string, OptimizelyVariation>();

            foreach (Variation variation in variations)
            {
                var variablesMap = MergeFeatureVariables(
                    featureVariableIdMap,
                    featureId,
                    variation.FeatureVariableUsageInstances,
                    variation.IsFeatureEnabled);

                var optimizelyVariation = new OptimizelyVariation(variation.Id,
                                                                  variation.Key,
                                                                  variation.FeatureEnabled,
                                                                  variablesMap);

                variationsMap.Add(variation.Key, optimizelyVariation);
            }

            return(variationsMap);
        }