private Threshold ExpandThreshold(T resource, Threshold threshold) { if (threshold.ThresholdType == ThresholdType.PercentageOf) { var fraction = threshold.Value / 100; var property = _attributes.GetValue(resource, threshold.SourceAttribute); threshold = new Threshold { ThresholdType = ThresholdType.Absolute, Value = fraction * (double)property }; } return(threshold); }
private async Task <Threshold> ExpandThreshold(T resource, TAlarmConfig config, Threshold threshold) { if (threshold.ThresholdType == ThresholdType.PercentageOf) { var fraction = threshold.Value / 100; var property = await _attributeProvider.GetValue(resource, config, threshold.SourceAttribute); threshold = new Threshold { ThresholdType = ThresholdType.Absolute, Value = fraction * (double)property }; } return(threshold); }
public static async Task <Threshold> ExpandThreshold <T, TAlarmConfig>( IResourceAttributesProvider <T, TAlarmConfig> attributeProvider, T resource, TAlarmConfig config, Threshold threshold) where TAlarmConfig : class, IServiceAlarmConfig <TAlarmConfig>, new() { if (threshold.ThresholdType == ThresholdType.PercentageOf) { var fraction = threshold.Value / 100; var property = await attributeProvider.GetValue(resource, config, threshold.SourceAttribute); threshold = new Threshold { ThresholdType = ThresholdType.Absolute, Value = fraction * (double)property }; } return(threshold); }