private string FormatNumber( NumberStyleRule rule, Number? number, CultureInfo culture ) #endif { string format; IValueConverter converter; // select format and value converter if ( rule == null ) { format = DefaultFormat; converter = DefaultValueConverter; } else { format = rule.Format; converter = rule.ValueConverter; } if ( number == null ) { // give the value converter an opportunity to handle null if ( converter != null ) { #if NETFX_CORE return (string) converter.Convert( null, typeof( string ), null, language ); #else return (string) converter.Convert( null, typeof( string ), null, culture ); #endif } return null; } // use converter first, then format if ( converter != null ) { #if NETFX_CORE return (string) converter.Convert( number.Value, typeof( string ), null, language ); #else return (string) converter.Convert( number.Value, typeof( string ), null, culture ); #endif } #if NETFX_CORE var culture = Util.GetCultureFromLanguage( language ); #endif if ( !string.IsNullOrEmpty( format ) ) return number.Value.ToString( format, culture ); return number.Value.ToString( culture ); }
private string FormatNumber( NumberStyleRule rule, Number? number, string language )