コード例 #1
0
        /// <summary>
        /// Formats the given value into an abbreviated format string.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="format">The format.</param>
        /// <param name="truncated">if set to <c>true</c> [truncated].</param>
        /// <param name="culture">The culture.</param>
        /// <returns></returns>
        public static string Format(decimal value, AbbreviationFormat format, bool truncated = true, CultureInfo culture = null)
        {
            if (culture == null)
                culture = CultureConstants.DefaultCulture;

            decimal abs = Math.Abs(value);
            if (format == AbbreviationFormat.AbbreviationWords)
            {
                if (abs >= 1E9M)
                    return Format(" Billions", value / 1E9M, truncated, culture);
                if (abs >= 1E6M)
                    return Format(" Millions", value / 1E6M, truncated, culture);

                return abs >= 1E3M
                    ? Format(" Thousands", value / 1E3M, truncated, culture)
                    : Format(String.Empty, value, truncated, culture);
            }

            if (abs >= 1E9M)
                return Format(" B", value / 1E9M, truncated, culture);
            if (abs >= 1E6M)
                return Format(" M", value / 1E6M, truncated, culture);

            return abs >= 1E3M ? Format(" K", value / 1E3M, truncated, culture) : Format(String.Empty, value, truncated, culture);
        }
コード例 #2
0
ファイル: MarketOrder.cs プロジェクト: wow4all/evemu_server
 /// <summary>
 /// Formats the given price to a readable string.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static string Format(decimal value, AbbreviationFormat format)
 {
     decimal abs = Math.Abs(value);
     if (format == AbbreviationFormat.AbbreviationWords)
     {
         if (abs >= 1E9M)
             return Format("Billions", value / 1E9M);
         if (abs >= 1E6M)
             return Format("Millions", value / 1E6M);
         if (abs >= 1E3M)
             return Format("Thousands", value / 1E3M);
         
         return Format("", value);
     }
     else
     {
         if (abs >= 1E9M)
             return Format("B", value / 1E9M);
         if (abs >= 1E6M)
             return Format("M", value / 1E6M);
         if (abs >= 1E3M)
             return Format("K", value / 1E3M);
         
         return Format("", value);
     }
 }
コード例 #3
0
 /// <summary>
 /// Formats the given value into an abbreviated format string.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="format">The format.</param>
 /// <param name="truncated">if set to <c>true</c> [truncated].</param>
 /// <param name="culture">The culture.</param>
 /// <returns></returns>
 public static string Format(long value, AbbreviationFormat format, bool truncated = true, CultureInfo culture = null)
     => Format(Convert.ToDecimal(value), format, truncated, culture);