public string Calculate(DSTCalculation data, DSTCalculationType type) { switch (type) { case DSTCalculationType.Speed: Speed speed = CalculateSpeed(data); return($"Speed = {speed.As(data.SpeedUnit)}{Speed.GetAbbreviation(data.SpeedUnit)}"); case DSTCalculationType.Distance: Length distance = CalculateDistance(data); return($"Distance = {distance.As(data.DistanceUnit)} {Length.GetAbbreviation(data.DistanceUnit)}"); case DSTCalculationType.Time: TimeSpan time = CalculateTime(data); return($"Time = {FormatTime(time)} "); default: throw new Exception("Unsupported Action"); } }
public async Task Calculate(DSTCalculationType type) { switch (type) { case DSTCalculationType.Distance: var distance = _calculationService.Calculate(DistanceCalculation, type); DistanceResult = distance; break; case DSTCalculationType.Speed: var speed = _calculationService.Calculate(SpeedCalculation, type); SpeedResult = speed; //await _dialogService.DisplayAlertAsync("Result", speed,"Ok"); break; case DSTCalculationType.Time: var time = _calculationService.Calculate(TimeCalculation, type); TimeResult = time; //await _dialogService.DisplayAlertAsync("Result", speed,"Ok"); break; } }