public ExperimentManager (params Type[] experimentRegistries)
        {
            experiments = new List<Experiment> (FindExperiments (experimentRegistries));

            // Restore currentExperiment
            var id = ServiceContainer.Resolve<ISettingsStore> ().ExperimentId;
            if (id != null) {
                currentExperiment = experiments.FirstOrDefault (e => e.Id == id);
            }
        }
        private static bool IsValid (Experiment e)
        {
            if (e == null || !e.Enabled) {
                return false;
            }

            var now = Time.UtcNow;
            if (e.StartTime != null && e.StartTime.ToUtc() > now) {
                return false;
            }
            if (e.EndTime != null && e.EndTime.ToUtc() < now) {
                return false;
            }

            return true;
        }
        public void NextExperiment (bool isFreshInstall)
        {
            // If the current experiment is still valid, do nothing.
            if (IsValid (CurrentExperiment)) {
                return;
            }

            var validExperiments = GetPossibleNextExperiments (isFreshInstall);

            // Choose experiment or no experiment. Equal probability of any outcome.
            var idx = RandomNumber (validExperiments.Count + 1);
            if (idx < validExperiments.Count) {
                CurrentExperiment = validExperiments [idx];
            } else {
                CurrentExperiment = null;
            }
        }