コード例 #1
0
        /// <summary>The is enabled.</summary>
        /// <param name="feature">The feature.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        /// <exception cref="FeatureToggleNotConfiguredException">a feature toggle not configured in azure exception. This will trigger if a particular feature flag is not present within the Azure App Configuration project for a particular environment</exception>
        public static bool IsEnabled(FeatureToggles feature)
        {
            try
            {
                var featureName = feature.ToString();
                var val         = Flags.FirstOrDefault(x => x.Id == featureName);
                if (val == null)
                {
                    throw new FeatureToggleNotConfiguredException(featureName);
                }

                return(val.Enabled);
            }
            catch (FeatureToggleNotConfiguredException ex)
            {
                log.LogError(ex.Message, ex);
                return(false);
            }
        }