Beispiel #1
0
        private static string GetCurrencyFormat(NumberFormatInfo numberFormatInfo, int precision)
        {
            string currencyDecimalSeparator = NumberFormatInfo.InvariantInfo.CurrencyDecimalSeparator;
            string currencyGroupSeparator   = NumberFormatInfo.InvariantInfo.CurrencyGroupSeparator;

            int[]  currencyGroupSizes      = numberFormatInfo.CurrencyGroupSizes;
            int    currencyNegativePattern = numberFormatInfo.CurrencyNegativePattern;
            int    currencyPositivePattern = numberFormatInfo.CurrencyPositivePattern;
            string text  = "\"" + numberFormatInfo.CurrencySymbol + "\"";
            string text2 = '\\' + numberFormatInfo.NegativeSign;
            int    num   = 3;

            if (currencyGroupSizes.Length > 0)
            {
                num = currencyGroupSizes[0];
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("#");
            stringBuilder.Append(currencyGroupSeparator);
            for (int i = 0; i < num - 1; i++)
            {
                stringBuilder.Append("#");
            }
            stringBuilder.Append('0');
            if (0 < precision)
            {
                stringBuilder.Append(currencyDecimalSeparator);
            }
            for (int j = 0; j < precision; j++)
            {
                stringBuilder.Append('0');
            }
            StringBuilder stringBuilder2 = new StringBuilder(string.Format(CultureInfo.InvariantCulture, FormatHandler.GetPositiveCurrencyPattern(currencyPositivePattern), stringBuilder.ToString(), text));

            stringBuilder2.Append(";");
            stringBuilder2.Append(string.Format(CultureInfo.InvariantCulture, FormatHandler.GetNegativeCurrencyPattern(currencyNegativePattern), stringBuilder.ToString(), text, text2));
            return(stringBuilder2.ToString());
        }