コード例 #1
0
        /// <summary>
        /// Get's all Feature Toggles from the JSON files that exist for the provided environment.
        /// </summary>
        /// <param name="environment">EnvironmentEnum e.g. Local, Dev, QAS, Stage, Prod</param>
        /// <returns>A collection of FeatureToggles for the environment.</returns>
        public List <FeatureToggle> GetAllFeatureTogglesForEnvironment(EnvironmentEnum environment)
        {
            var jsonFiles = GetJsonFiles();

            var result = new List <FeatureToggle>();

            foreach (var jsonFile in jsonFiles)
            {
                var featureToggle = GetFeatureToggleFromJson(jsonFile);

                if (environment.Has <EnvironmentEnum>(featureToggle.Environment) || featureToggle.SubFeatureToggles.Where(w => environment.Has <EnvironmentEnum>(w.Environment) == true).Count() > 0)
                {
                    result.Add(featureToggle);
                }
            }

            return(result);
        }
コード例 #2
0
        public List <FeatureToggle> GetAllFeatureTogglesForPlatformAndEnvironment(PlatformEnum platform, EnvironmentEnum environment)
        {
            var jsonFiles = GetJsonFiles();

            var result = new List <FeatureToggle>();

            foreach (var jsonFile in jsonFiles)
            {
                var featureToggle = GetFeatureToggleFromJson(jsonFile);

                if (platform.Has <PlatformEnum>(featureToggle.Platform) &&
                    (environment.Has <EnvironmentEnum>(featureToggle.Environment) ||
                     (featureToggle.SubFeatureToggles != null &&
                      featureToggle.SubFeatureToggles.Where(w => w.Platform != 0 && platform.Has <PlatformEnum>(w.Platform) && environment.Has <EnvironmentEnum>(w.Environment)).Count() > 0)))
                {
                    result.Add(featureToggle);
                }
            }

            return(result);
        }
コード例 #3
0
        public List <FeatureToggle> GetAllFeatureToggles(PlatformEnum platform, EnvironmentEnum environment, string application)
        {
            var jsonFiles = GetJsonFiles();

            var result = new List <FeatureToggle>();

            foreach (var jsonFile in jsonFiles)
            {
                var featureToggle = GetFeatureToggleFromJson(jsonFile);

                if ((application.ToUpper() == "ALL" || string.IsNullOrEmpty(featureToggle.Application) || featureToggle.Application.ToUpper() == "ALL" || featureToggle.Application.ToUpper() == application.ToUpper()) &&
                    platform.Has <PlatformEnum>(featureToggle.Platform) &&
                    (environment.Has <EnvironmentEnum>(featureToggle.Environment) ||
                     (featureToggle.SubFeatureToggles != null &&
                      featureToggle.SubFeatureToggles.Where(w => w.Platform != 0 && platform.Has <PlatformEnum>(w.Platform) && environment.Has <EnvironmentEnum>(w.Environment)).Count() > 0)))
                {
                    result.Add(featureToggle);
                }
            }

            return(result);
        }