private void GetEnvironmentVariablesForFeature(NuGetFeatureFlagConstants featureFlag, out bool isFeatureForcedEnabled, out bool isFeatureForcedDisabled)
        {
            isFeatureForcedEnabled  = false;
            isFeatureForcedDisabled = false;
            if (!string.IsNullOrEmpty(featureFlag.EnvironmentVariable))
            {
                string envVarOverride = _environmentVariableReader.GetEnvironmentVariable(featureFlag.EnvironmentVariable);

                isFeatureForcedDisabled = envVarOverride == "0";
                isFeatureForcedEnabled  = envVarOverride == "1";
            }
        }
        public async Task <bool> IsFeatureEnabledAsync(NuGetFeatureFlagConstants featureFlag)
        {
            GetEnvironmentVariablesForFeature(featureFlag, out bool isFeatureForcedEnabled, out bool isFeatureForcedDisabled);
            // Perform the check from the feature flag service only once.
            // There are events sent for targetted notification changes, but we don't listen to those at this point.
            if (!_featureFlagCache.TryGetValue(featureFlag.Name, out bool featureEnabled))
            {
                var featureFlagService = await _ivsFeatureFlags.GetValueAsync();

                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                featureEnabled = featureFlagService.IsFeatureEnabled(featureFlag.Name, defaultValue: featureFlag.DefaultState);
                _featureFlagCache.Add(featureFlag.Name, featureEnabled);
            }
            return(!isFeatureForcedDisabled && (isFeatureForcedEnabled || featureEnabled));
        }