@@ -137,23 +137,17 @@ public static object ParseAbstractType<T>(StringSegment value)
137
137
public static object ParseQuotedPrimitive ( string value )
138
138
{
139
139
var fn = JsConfig . ParsePrimitiveFn ;
140
- if ( fn != null )
141
- {
142
- var result = fn ( value ) ;
143
- if ( result != null )
144
- return result ;
145
- }
140
+ var result = fn ? . Invoke ( value ) ;
141
+ if ( result != null )
142
+ return result ;
146
143
147
144
if ( string . IsNullOrEmpty ( value ) )
148
145
return null ;
149
146
150
- Guid guidValue ;
151
- if ( Guid . TryParse ( value , out guidValue ) ) return guidValue ;
147
+ if ( Guid . TryParse ( value , out Guid guidValue ) ) return guidValue ;
152
148
153
149
if ( value . StartsWith ( DateTimeSerializer . EscapedWcfJsonPrefix , StringComparison . Ordinal ) || value . StartsWith ( DateTimeSerializer . WcfJsonPrefix , StringComparison . Ordinal ) )
154
- {
155
150
return DateTimeSerializer . ParseWcfJsonDate ( value ) ;
156
- }
157
151
158
152
if ( JsConfig . DateHandler == DateHandler . ISO8601 )
159
153
{
@@ -188,24 +182,19 @@ public static object ParseQuotedPrimitive(string value)
188
182
public static object ParsePrimitive ( StringSegment value )
189
183
{
190
184
var fn = JsConfig . ParsePrimitiveFn ;
191
- if ( fn != null )
192
- {
193
- var result = fn ( value . Value ) ;
194
- if ( result != null )
195
- return result ;
196
- }
185
+ var result = fn ? . Invoke ( value . Value ) ;
186
+ if ( result != null )
187
+ return result ;
197
188
198
189
if ( value . IsNullOrEmpty ( ) )
199
190
return null ;
200
191
201
- bool boolValue ;
202
- if ( value . TryParseBoolean ( out boolValue ) )
192
+ if ( value . TryParseBoolean ( out bool boolValue ) )
203
193
return boolValue ;
204
194
205
195
// Parse as decimal
206
- decimal decimalValue ;
207
196
var acceptDecimal = JsConfig . ParsePrimitiveFloatingPointTypes . Has ( ParseAsType . Decimal ) ;
208
- var isDecimal = value . TryParseDecimal ( out decimalValue ) ;
197
+ var isDecimal = value . TryParseDecimal ( out decimal decimalValue ) ;
209
198
210
199
// Check if the number is an Primitive Integer type given that we have a decimal
211
200
if ( isDecimal && decimalValue == decimal . Truncate ( decimalValue ) )
@@ -229,15 +218,13 @@ public static object ParsePrimitive(StringSegment value)
229
218
if ( isDecimal && acceptDecimal )
230
219
return decimalValue ;
231
220
232
- float floatValue ;
233
221
var acceptFloat = JsConfig . ParsePrimitiveFloatingPointTypes . HasFlag ( ParseAsType . Single ) ;
234
- var isFloat = value . TryParseFloat ( out floatValue ) ;
222
+ var isFloat = value . TryParseFloat ( out float floatValue ) ;
235
223
if ( acceptFloat && isFloat )
236
224
return floatValue ;
237
225
238
- double doubleValue ;
239
226
var acceptDouble = JsConfig . ParsePrimitiveFloatingPointTypes . HasFlag ( ParseAsType . Double ) ;
240
- var isDouble = value . TryParseDouble ( out doubleValue ) ;
227
+ var isDouble = value . TryParseDouble ( out double doubleValue ) ;
241
228
if ( acceptDouble && isDouble )
242
229
return doubleValue ;
243
230
@@ -347,14 +334,13 @@ private static SetMemberDelegate GetSetPropertyMethod(TypeConfig typeConfig, Pro
347
334
FieldInfo fieldInfo = null ;
348
335
if ( ! propertyInfo . CanWrite )
349
336
{
350
- //TODO: What string comparison is used in SST?
351
- string fieldNameFormat = Env . IsMono ? "<{0}>" : "<{0}>i__Field" ;
337
+ var fieldNameFormat = Env . IsMono ? "<{0}>" : "<{0}>i__Field" ;
352
338
var fieldName = string . Format ( fieldNameFormat , propertyInfo . Name ) ;
353
339
354
340
var fieldInfos = typeConfig . Type . GetWritableFields ( ) ;
355
341
foreach ( var f in fieldInfos )
356
342
{
357
- if ( f . IsInitOnly && f . FieldType == propertyInfo . PropertyType && f . Name == fieldName )
343
+ if ( f . IsInitOnly && f . FieldType == propertyInfo . PropertyType && f . Name . EqualsIgnoreCase ( fieldName ) )
358
344
{
359
345
fieldInfo = f ;
360
346
break ;
0 commit comments