Format() public method

public Format ( double value ) : string
value double
return string
Esempio n. 1
0
        public string FormatNumberDynamic(double value, string formatPicture, XmlQualifiedName decimalFormatName, string errorMessageName)
        {
            DecimalFormat?format;

            if (_decimalFormats == null || !_decimalFormats.TryGetValue(decimalFormatName, out format))
            {
                throw new XslTransformException(SR.Xslt_NoDecimalFormat, errorMessageName);
            }

            DecimalFormatter formatter = new DecimalFormatter(formatPicture, format);

            return(formatter.Format(value));
        }
        public string FormatNumberDynamic(double value, string formatPicture, XmlQualifiedName decimalFormatName, string errorMessageName)
        {
            DecimalFormatDecl format;

            if (decimalFormats != null && decimalFormats.Contains(decimalFormatName))
            {
                format = decimalFormats[decimalFormatName];
            }
            else
            {
                if (decimalFormatName != DecimalFormatDecl.Default.Name)
                {
                    throw new XslTransformException(Res.Xslt_NoDecimalFormat, errorMessageName);
                }
                format = DecimalFormatDecl.Default;
            }

            DecimalFormatter formatter = CreateDecimalFormatter(formatPicture, format.InfinitySymbol, format.NanSymbol, new string(format.Characters));

            return(formatter.Format(value));
        }
Esempio n. 3
0
        public string FormatNumberDynamic(double value, string formatPicture, XmlQualifiedName decimalFormatName, string errorMessageName) {
            DecimalFormat format;
            if (decimalFormats == null || ! decimalFormats.TryGetValue(decimalFormatName, out format)) {
                throw new XslTransformException(Res.Xslt_NoDecimalFormat, errorMessageName);
            }

            DecimalFormatter formatter = new DecimalFormatter(formatPicture, format);
            return formatter.Format(value);
        }