/// <summary>Formats the IBAN with spaces.</summary> private string ToFormattedString() { if (m_Value == default) { return(string.Empty); } if (m_Value == Unknown.m_Value) { return("?"); } return(FormattedPattern.Replace(m_Value, "$0 ")); }
/// <summary>Returns a formatted <see cref="string"/> that represents the current stream size.</summary> /// <param name="format"> /// The format that this describes the formatting. /// </param> /// <param name="formatProvider"> /// The format provider. /// </param> /// <remarks> /// There are basically two ways to format the stream size. The first one is /// automatic. Based on the size the extension is chosen (byte, kB, MB, GB, ect.). /// This can be specified by a s/S (short notation) and a f/F (full notation). /// /// The other option is to specify the extension explicitly. So Megabyte, /// kB, ect. No extension is also possible. /// /// Short notation: /// 8900.ToString("s") => 8900b /// 238900.ToString("s") => 238.9kb /// 238900.ToString(" S") => 238.9 kB /// 238900.ToString("0000.00 S") => 0238.90 kB /// /// Full notation: /// 8900.ToString("0.0 f") => 8900.0 byte /// 238900.ToString("0 f") => 234 kilobyte /// 1238900.ToString("0.00 F") => 1.24 Megabyte /// /// Custom: /// 8900.ToString("0.0 kb") => 8.9 kb /// 238900.ToString("0.0 MB") => 0.2 MB /// 1238900.ToString("#,##0.00 Kilobyte") => 1,239.00 Kilobyte /// 1238900.ToString("#,##0") => 1,238,900 /// </remarks> public string ToString(string format, IFormatProvider formatProvider) { string formatted; if (StringFormatter.TryApplyCustomFormatter(format, this, formatProvider, out formatted)) { return(formatted); } var match = FormattedPattern.Match(format ?? string.Empty); if (match.Success) { return(ToFormattedString(formatProvider, match)); } var streamSizeMarker = GetStreamSizeMarker(format); var decimalFormat = GetWithoutStreamSizeMarker(format, streamSizeMarker); var mp = GetMultiplier(streamSizeMarker); decimal size = (decimal)m_Value / (decimal)mp; return(size.ToString(decimalFormat, formatProvider) + streamSizeMarker); }