コード例 #1
0
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(value);
            }

            var currency = System.Convert.ToDouble(value);

            return(CultureProvider.FormatCurrency(currency));
        }
コード例 #2
0
        public string GetFareEstimateDisplay(DirectionInfo direction)
        {
            var fareEstimate = _localize[_appSettings.Data.DestinationIsRequired
                ? "NoFareTextIfDestinationIsRequired"
                : "NoFareText"];

            if (direction.ValidationResult != null &&
                direction.ValidationResult.HasError)
            {
                fareEstimate = direction.ValidationResult.Message;
            }
            else if (direction.Distance.HasValue)
            {
                var willShowFare = direction.Price.HasValue && direction.Price.Value > 0;
                if (willShowFare)
                {
                    var isOverMaxFare = direction.Price.Value > _appSettings.Data.MaxFareEstimate;

                    var formattedCurrency = CultureProvider.FormatCurrency(direction.Price.Value);

                    fareEstimate = String.Format(
                        CultureProvider.CultureInfo,
                        _localize[isOverMaxFare
                            ? "EstimatePriceOver100"
                            : "EstimatePriceFormat"],
                        formattedCurrency,
                        direction.FormattedDistance);
                }
                else
                {
                    fareEstimate = _localize["EstimatedFareNotAvailable"];
                }
            }

            return(fareEstimate);
        }