@@ -29,7 +29,7 @@ public class DynamicSByte : IDynamicNumber
29
29
public Type Type => typeof ( sbyte ) ;
30
30
31
31
[ 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 ) ;
33
33
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
34
34
public object ConvertFrom ( object value ) => this . ParseString ( value )
35
35
?? System . Convert . ToSByte ( value ) ;
@@ -59,7 +59,7 @@ public class DynamicByte : IDynamicNumber
59
59
public Type Type => typeof ( byte ) ;
60
60
61
61
[ 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 ) ;
63
63
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
64
64
public object ConvertFrom ( object value ) => this . ParseString ( value )
65
65
?? System . Convert . ToByte ( value ) ;
@@ -89,7 +89,7 @@ public class DynamicShort : IDynamicNumber
89
89
public Type Type => typeof ( short ) ;
90
90
91
91
[ 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 ) ;
93
93
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
94
94
public object ConvertFrom ( object value ) => this . ParseString ( value )
95
95
?? System . Convert . ToInt16 ( value ) ;
@@ -119,7 +119,7 @@ public class DynamicUShort : IDynamicNumber
119
119
public Type Type => typeof ( ushort ) ;
120
120
121
121
[ 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 ) ;
123
123
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
124
124
public object ConvertFrom ( object value ) => this . ParseString ( value )
125
125
?? System . Convert . ToUInt16 ( value ) ;
@@ -149,7 +149,7 @@ public class DynamicInt : IDynamicNumber
149
149
public Type Type => typeof ( int ) ;
150
150
151
151
[ 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 ) ;
153
153
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
154
154
public object ConvertFrom ( object value ) => this . ParseString ( value )
155
155
?? System . Convert . ToInt32 ( value ) ;
@@ -179,7 +179,7 @@ public class DynamicUInt : IDynamicNumber
179
179
public Type Type => typeof ( uint ) ;
180
180
181
181
[ 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 ) ;
183
183
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
184
184
public object ConvertFrom ( object value ) => this . ParseString ( value )
185
185
?? System . Convert . ToUInt32 ( value ) ;
@@ -209,7 +209,7 @@ public class DynamicLong : IDynamicNumber
209
209
public Type Type => typeof ( long ) ;
210
210
211
211
[ 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 ) ;
213
213
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
214
214
public object ConvertFrom ( object value ) => this . ParseString ( value )
215
215
?? System . Convert . ToInt64 ( value ) ;
@@ -239,7 +239,7 @@ public class DynamicULong : IDynamicNumber
239
239
public Type Type => typeof ( ulong ) ;
240
240
241
241
[ 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 ) ;
243
243
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
244
244
public object ConvertFrom ( object value ) => this . ParseString ( value )
245
245
?? System . Convert . ToUInt64 ( value ) ;
@@ -269,7 +269,7 @@ public class DynamicFloat : IDynamicNumber
269
269
public Type Type => typeof ( float ) ;
270
270
271
271
[ 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 ) ;
273
273
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
274
274
public object ConvertFrom ( object value ) => this . ParseString ( value )
275
275
?? System . Convert . ToSingle ( value ) ;
@@ -299,7 +299,7 @@ public class DynamicDouble : IDynamicNumber
299
299
public Type Type => typeof ( double ) ;
300
300
301
301
[ 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 ) ;
303
303
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
304
304
public object ConvertFrom ( object value ) => this . ParseString ( value )
305
305
?? System . Convert . ToDouble ( value ) ;
@@ -329,7 +329,7 @@ public class DynamicDecimal : IDynamicNumber
329
329
public Type Type => typeof ( decimal ) ;
330
330
331
331
[ 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 ) ;
333
333
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
334
334
public object ConvertFrom ( object value ) => this . ParseString ( value )
335
335
?? System . Convert . ToDecimal ( value ) ;
@@ -540,7 +540,7 @@ public static bool TryParseIntoBestFit(string strValue, out object result)
540
540
return false ;
541
541
542
542
var segValue = new StringSegment ( strValue ) ;
543
- result = segValue . ParseNumber ( ) ;
543
+ result = segValue . ParseNumber ( bestFit : true ) ;
544
544
return result != null ;
545
545
}
546
546
}
0 commit comments