@@ -29,7 +29,7 @@ public class DynamicSByte : IDynamicNumber
2929 public Type Type => typeof ( sbyte ) ;
3030
3131 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
32- public sbyte Convert ( object value ) => System . Convert . ToSByte ( value ) ;
32+ public sbyte Convert ( object value ) => System . Convert . ToSByte ( this . ParseString ( value ) ?? value ) ;
3333 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
3434 public object ConvertFrom ( object value ) => this . ParseString ( value )
3535 ?? System . Convert . ToSByte ( value ) ;
@@ -59,7 +59,7 @@ public class DynamicByte : IDynamicNumber
5959 public Type Type => typeof ( byte ) ;
6060
6161 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
62- public byte Convert ( object value ) => System . Convert . ToByte ( value ) ;
62+ public byte Convert ( object value ) => System . Convert . ToByte ( this . ParseString ( value ) ?? value ) ;
6363 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
6464 public object ConvertFrom ( object value ) => this . ParseString ( value )
6565 ?? System . Convert . ToByte ( value ) ;
@@ -89,7 +89,7 @@ public class DynamicShort : IDynamicNumber
8989 public Type Type => typeof ( short ) ;
9090
9191 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
92- public short Convert ( object value ) => System . Convert . ToInt16 ( value ) ;
92+ public short Convert ( object value ) => System . Convert . ToInt16 ( this . ParseString ( value ) ?? value ) ;
9393 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
9494 public object ConvertFrom ( object value ) => this . ParseString ( value )
9595 ?? System . Convert . ToInt16 ( value ) ;
@@ -119,7 +119,7 @@ public class DynamicUShort : IDynamicNumber
119119 public Type Type => typeof ( ushort ) ;
120120
121121 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
122- public ushort Convert ( object value ) => System . Convert . ToUInt16 ( value ) ;
122+ public ushort Convert ( object value ) => System . Convert . ToUInt16 ( this . ParseString ( value ) ?? value ) ;
123123 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
124124 public object ConvertFrom ( object value ) => this . ParseString ( value )
125125 ?? System . Convert . ToUInt16 ( value ) ;
@@ -149,7 +149,7 @@ public class DynamicInt : IDynamicNumber
149149 public Type Type => typeof ( int ) ;
150150
151151 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
152- public int Convert ( object value ) => System . Convert . ToInt32 ( value ) ;
152+ public int Convert ( object value ) => System . Convert . ToInt32 ( this . ParseString ( value ) ?? value ) ;
153153 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
154154 public object ConvertFrom ( object value ) => this . ParseString ( value )
155155 ?? System . Convert . ToInt32 ( value ) ;
@@ -179,7 +179,7 @@ public class DynamicUInt : IDynamicNumber
179179 public Type Type => typeof ( uint ) ;
180180
181181 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
182- public uint Convert ( object value ) => System . Convert . ToUInt32 ( value ) ;
182+ public uint Convert ( object value ) => System . Convert . ToUInt32 ( this . ParseString ( value ) ?? value ) ;
183183 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
184184 public object ConvertFrom ( object value ) => this . ParseString ( value )
185185 ?? System . Convert . ToUInt32 ( value ) ;
@@ -209,7 +209,7 @@ public class DynamicLong : IDynamicNumber
209209 public Type Type => typeof ( long ) ;
210210
211211 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
212- public long Convert ( object value ) => System . Convert . ToInt64 ( value ) ;
212+ public long Convert ( object value ) => System . Convert . ToInt64 ( this . ParseString ( value ) ?? value ) ;
213213 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
214214 public object ConvertFrom ( object value ) => this . ParseString ( value )
215215 ?? System . Convert . ToInt64 ( value ) ;
@@ -239,7 +239,7 @@ public class DynamicULong : IDynamicNumber
239239 public Type Type => typeof ( ulong ) ;
240240
241241 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
242- public ulong Convert ( object value ) => System . Convert . ToUInt64 ( value ) ;
242+ public ulong Convert ( object value ) => System . Convert . ToUInt64 ( this . ParseString ( value ) ?? value ) ;
243243 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
244244 public object ConvertFrom ( object value ) => this . ParseString ( value )
245245 ?? System . Convert . ToUInt64 ( value ) ;
@@ -269,7 +269,7 @@ public class DynamicFloat : IDynamicNumber
269269 public Type Type => typeof ( float ) ;
270270
271271 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
272- public float Convert ( object value ) => System . Convert . ToSingle ( value ) ;
272+ public float Convert ( object value ) => System . Convert . ToSingle ( this . ParseString ( value ) ?? value ) ;
273273 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
274274 public object ConvertFrom ( object value ) => this . ParseString ( value )
275275 ?? System . Convert . ToSingle ( value ) ;
@@ -299,7 +299,7 @@ public class DynamicDouble : IDynamicNumber
299299 public Type Type => typeof ( double ) ;
300300
301301 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
302- public double Convert ( object value ) => System . Convert . ToDouble ( value ) ;
302+ public double Convert ( object value ) => System . Convert . ToDouble ( this . ParseString ( value ) ?? value ) ;
303303 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
304304 public object ConvertFrom ( object value ) => this . ParseString ( value )
305305 ?? System . Convert . ToDouble ( value ) ;
@@ -329,7 +329,7 @@ public class DynamicDecimal : IDynamicNumber
329329 public Type Type => typeof ( decimal ) ;
330330
331331 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
332- public decimal Convert ( object value ) => System . Convert . ToDecimal ( value ) ;
332+ public decimal Convert ( object value ) => System . Convert . ToDecimal ( this . ParseString ( value ) ?? value ) ;
333333 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
334334 public object ConvertFrom ( object value ) => this . ParseString ( value )
335335 ?? System . Convert . ToDecimal ( value ) ;
@@ -540,7 +540,7 @@ public static bool TryParseIntoBestFit(string strValue, out object result)
540540 return false ;
541541
542542 var segValue = new StringSegment ( strValue ) ;
543- result = segValue . ParseNumber ( ) ;
543+ result = segValue . ParseNumber ( bestFit : true ) ;
544544 return result != null ;
545545 }
546546 }
0 commit comments