@@ -19,35 +19,38 @@ namespace OnixLabs.Units;
1919
2020internal static class ReadOnlySpanExtensions
2121{
22- public static ( string specifier , int scale ) GetSpecifierAndScale ( this ReadOnlySpan < char > format , string defaultSpecifier )
22+ extension ( ReadOnlySpan < char > format )
2323 {
24- const char plus = '+' ;
25- const char minus = '-' ;
24+ public ( string specifier , int scale ) GetSpecifierAndScale ( string defaultSpecifier )
25+ {
26+ const char plus = '+' ;
27+ const char minus = '-' ;
2628
27- int defaultScale = CultureInfo . CurrentCulture . NumberFormat . NumberDecimalDigits ;
29+ int defaultScale = CultureInfo . CurrentCulture . NumberFormat . NumberDecimalDigits ;
2830
29- if ( format . IsEmpty )
30- return ( defaultSpecifier , defaultScale ) ;
31+ if ( format . IsEmpty )
32+ return ( defaultSpecifier , defaultScale ) ;
3133
32- int index = 0 ;
34+ int index = 0 ;
3335
34- while ( index < format . Length && char . IsLetter ( format [ index ] ) )
35- index ++ ;
36+ while ( index < format . Length && char . IsLetter ( format [ index ] ) )
37+ index ++ ;
3638
37- if ( index == 0 )
38- throw new FormatException ( "Format must start with a letter specifier." ) ;
39+ if ( index == 0 )
40+ throw new FormatException ( "Format must start with a letter specifier." ) ;
3941
40- string specifier = new ( format [ ..index ] ) ;
41- ReadOnlySpan < char > scaleCharacters = format [ index ..] ;
42+ string specifier = new ( format [ ..index ] ) ;
43+ ReadOnlySpan < char > scaleCharacters = format [ index ..] ;
4244
43- if ( scaleCharacters . IsEmpty )
44- return ( specifier , defaultScale ) ;
45+ if ( scaleCharacters . IsEmpty )
46+ return ( specifier , defaultScale ) ;
4547
46- if ( scaleCharacters [ 0 ] is plus or minus )
47- throw new FormatException ( $ "Scale must not begin with a leading '{ plus } ' or '{ minus } ' sign.") ;
48+ if ( scaleCharacters [ 0 ] is plus or minus )
49+ throw new FormatException ( $ "Scale must not begin with a leading '{ plus } ' or '{ minus } ' sign.") ;
4850
49- return int . TryParse ( scaleCharacters , NumberStyles . None , CultureInfo . InvariantCulture , out int scale )
50- ? ( specifier , scale )
51- : throw new FormatException ( "Scale must contain only decimal digits." ) ;
51+ return int . TryParse ( scaleCharacters , NumberStyles . None , CultureInfo . InvariantCulture , out int scale )
52+ ? ( specifier , scale )
53+ : throw new FormatException ( "Scale must contain only decimal digits." ) ;
54+ }
5255 }
5356}
0 commit comments