@@ -325,37 +325,19 @@ public string ClientReference
325325 /// <returns></returns>
326326 public string GetSerializationSettingsReference ( IType serializationType )
327327 {
328- SequenceType sequenceType = serializationType as SequenceType ;
329- DictionaryType dictionaryType = serializationType as DictionaryType ;
330- if ( serializationType . IsPrimaryType ( KnownPrimaryType . Date ) ||
331- ( sequenceType != null && sequenceType . ElementType is PrimaryType
332- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . Date ) ||
333- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
334- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . Date ) )
328+ if ( serializationType . IsOrContainsPrimaryType ( KnownPrimaryType . Date ) )
335329 {
336330 return "new DateJsonConverter()" ;
337331 }
338- else if ( serializationType . IsPrimaryType ( KnownPrimaryType . DateTimeRfc1123 ) ||
339- ( sequenceType != null && sequenceType . ElementType is PrimaryType
340- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . DateTimeRfc1123 ) ||
341- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
342- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . DateTimeRfc1123 ) )
332+ else if ( serializationType . IsOrContainsPrimaryType ( KnownPrimaryType . DateTimeRfc1123 ) )
343333 {
344334 return "new DateTimeRfc1123JsonConverter()" ;
345335 }
346- else if ( serializationType . IsPrimaryType ( KnownPrimaryType . Base64Url ) ||
347- ( sequenceType != null && sequenceType . ElementType is PrimaryType
348- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . Base64Url ) ||
349- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
350- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . Base64Url ) )
336+ else if ( serializationType . IsOrContainsPrimaryType ( KnownPrimaryType . Base64Url ) )
351337 {
352338 return "new Base64UrlJsonConverter()" ;
353339 }
354- else if ( serializationType . IsPrimaryType ( KnownPrimaryType . UnixTime ) ||
355- ( sequenceType != null && sequenceType . ElementType is PrimaryType
356- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . UnixTime ) ||
357- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
358- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . UnixTime ) )
340+ else if ( serializationType . IsOrContainsPrimaryType ( KnownPrimaryType . UnixTime ) )
359341 {
360342 return "new UnixTimeJsonConverter()" ;
361343 }
@@ -369,33 +351,18 @@ public string GetSerializationSettingsReference(IType serializationType)
369351 /// <returns></returns>
370352 public string GetDeserializationSettingsReference ( IType deserializationType )
371353 {
372- SequenceType sequenceType = deserializationType as SequenceType ;
373- DictionaryType dictionaryType = deserializationType as DictionaryType ;
374- if ( deserializationType . IsPrimaryType ( KnownPrimaryType . Date ) ||
375- ( sequenceType != null && sequenceType . ElementType is PrimaryType
376- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . Date ) ||
377- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
378- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . Date ) )
354+ if ( deserializationType . IsOrContainsPrimaryType ( KnownPrimaryType . Date ) )
379355 {
380356 return "new DateJsonConverter()" ;
381357 }
382- else if ( deserializationType . IsPrimaryType ( KnownPrimaryType . Base64Url ) ||
383- ( sequenceType != null && sequenceType . ElementType is PrimaryType
384- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . Base64Url ) ||
385- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
386- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . Base64Url ) )
358+ else if ( deserializationType . IsOrContainsPrimaryType ( KnownPrimaryType . Base64Url ) )
387359 {
388360 return "new Base64UrlJsonConverter()" ;
389361 }
390- else if ( deserializationType . IsPrimaryType ( KnownPrimaryType . UnixTime ) ||
391- ( sequenceType != null && sequenceType . ElementType is PrimaryType
392- && ( ( PrimaryType ) sequenceType . ElementType ) . Type == KnownPrimaryType . UnixTime ) ||
393- ( dictionaryType != null && dictionaryType . ValueType is PrimaryType
394- && ( ( PrimaryType ) dictionaryType . ValueType ) . Type == KnownPrimaryType . UnixTime ) )
362+ else if ( deserializationType . IsOrContainsPrimaryType ( KnownPrimaryType . UnixTime ) )
395363 {
396364 return "new UnixTimeJsonConverter()" ;
397365 }
398-
399366 return ClientReference + ".DeserializationSettings" ;
400367 }
401368
0 commit comments