public async Task <TType> GetValueAsync <TType>( string featureName, ActivatorParameterDescriptor parameterDescriptor) { var feature = await _featuresStore.FindFeatureAsync(featureName); if (feature != null) { var parameter = await _featuresStore.FindParameterAsync(parameterDescriptor.Name, featureName, parameterDescriptor.ActivatorName); if (parameter != null) { try { return((TType)TypeDescriptor.GetConverter(typeof(TType)) .ConvertFromString(null, CultureInfo.InvariantCulture, parameter.Value)); } catch (Exception ex) { _logger.LogError($"The parameter with name {parameterDescriptor.Name} on feature {featureName} can't be converted to type {typeof(TType).Name}. The internal exception is {ex}"); } } else { _logger.LogWarning($"The parameter with name {parameterDescriptor.Name} is not configured on feature {featureName}."); } } else { _logger.LogWarning($"The feature with name {featureName} not exist on configured store."); } return(default(TType)); }
public async Task <bool> IsEnabledAsync(string featureName) { try { var feature = await _featuresStore.FindFeatureAsync(featureName); if (feature == null) { throw new ArgumentException(nameof(featureName)); } var types = await _featuresStore.FindFeatureActivatorsTypesAsync(featureName); foreach (var type in types) { var activator = (IFeatureActivator)_singleInstanceFactory(type); if (!await activator.IsActiveAsync(featureName)) { return(false); } } return(true); } catch (Exception ex) { if (_xabarilOptions.FailureMode == FailureMode.Throw) { throw; } else { _logger.LogError($"Error executing IsEnabled({featureName}), the inner exception is {ex.ToString()}"); return(false); } } }