@@ -29,7 +29,7 @@ public static JsConfigScope BeginScope()
2929 public static JsConfigScope With (
3030 bool ? convertObjectTypesIntoStringDictionary = null ,
3131 bool ? tryToParsePrimitiveTypeValues = null ,
32- bool ? tryToParseNumericType = null ,
32+ bool ? tryToParseNumericType = null ,
3333 bool ? includeNullValues = null ,
3434 bool ? includeDefaultEnums = null ,
3535 bool ? excludeTypeInfo = null ,
@@ -44,7 +44,7 @@ public static JsConfigScope With(
4444 string typeAttr = null ,
4545 Func < Type , string > typeWriter = null ,
4646 Func < string , Type > typeFinder = null ,
47- bool ? treatEnumAsInteger = null ,
47+ bool ? treatEnumAsInteger = null ,
4848 bool ? alwaysUseUtc = null ,
4949 bool ? assumeUtc = null ,
5050 bool ? appendUtcOffset = null ,
@@ -55,7 +55,8 @@ public static JsConfigScope With(
5555 EmptyCtorFactoryDelegate modelFactory = null ,
5656 string [ ] excludePropertyReferences = null )
5757 {
58- return new JsConfigScope {
58+ return new JsConfigScope
59+ {
5960 ConvertObjectTypesIntoStringDictionary = convertObjectTypesIntoStringDictionary ?? sConvertObjectTypesIntoStringDictionary ,
6061 TryToParsePrimitiveTypeValues = tryToParsePrimitiveTypeValues ?? sTryToParsePrimitiveTypeValues ,
6162 TryToParseNumericType = tryToParseNumericType ?? sTryToParseNumericType ,
@@ -91,8 +92,8 @@ public static bool ConvertObjectTypesIntoStringDictionary
9192 {
9293 get
9394 {
94- return ( JsConfigScope . Current != null ? JsConfigScope . Current . ConvertObjectTypesIntoStringDictionary : null )
95- ?? sConvertObjectTypesIntoStringDictionary
95+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ConvertObjectTypesIntoStringDictionary : null )
96+ ?? sConvertObjectTypesIntoStringDictionary
9697 ?? false ;
9798 }
9899 set
@@ -106,8 +107,8 @@ public static bool TryToParsePrimitiveTypeValues
106107 {
107108 get
108109 {
109- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParsePrimitiveTypeValues : null )
110- ?? sTryToParsePrimitiveTypeValues
110+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParsePrimitiveTypeValues : null )
111+ ?? sTryToParsePrimitiveTypeValues
111112 ?? false ;
112113 }
113114 set
@@ -116,20 +117,20 @@ public static bool TryToParsePrimitiveTypeValues
116117 }
117118 }
118119
119- private static bool ? sTryToParseNumericType ;
120- public static bool TryToParseNumericType
121- {
122- get
123- {
124- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParseNumericType : null )
125- ?? sTryToParseNumericType
126- ?? false ;
127- }
128- set
129- {
130- if ( ! sTryToParseNumericType . HasValue ) sTryToParseNumericType = value ;
131- }
132- }
120+ private static bool ? sTryToParseNumericType ;
121+ public static bool TryToParseNumericType
122+ {
123+ get
124+ {
125+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParseNumericType : null )
126+ ?? sTryToParseNumericType
127+ ?? false ;
128+ }
129+ set
130+ {
131+ if ( ! sTryToParseNumericType . HasValue ) sTryToParseNumericType = value ;
132+ }
133+ }
133134
134135 private static bool ? sIncludeNullValues ;
135136 public static bool IncludeNullValues
@@ -166,8 +167,8 @@ public static bool TreatEnumAsInteger
166167 {
167168 get
168169 {
169- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TreatEnumAsInteger : null )
170- ?? sTreatEnumAsInteger
170+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TreatEnumAsInteger : null )
171+ ?? sTreatEnumAsInteger
171172 ?? false ;
172173 }
173174 set
@@ -181,8 +182,8 @@ public static bool ExcludeTypeInfo
181182 {
182183 get
183184 {
184- return ( JsConfigScope . Current != null ? JsConfigScope . Current . ExcludeTypeInfo : null )
185- ?? sExcludeTypeInfo
185+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ExcludeTypeInfo : null )
186+ ?? sExcludeTypeInfo
186187 ?? false ;
187188 }
188189 set
@@ -196,8 +197,8 @@ public static bool IncludeTypeInfo
196197 {
197198 get
198199 {
199- return ( JsConfigScope . Current != null ? JsConfigScope . Current . IncludeTypeInfo : null )
200- ?? sIncludeTypeInfo
200+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . IncludeTypeInfo : null )
201+ ?? sIncludeTypeInfo
201202 ?? false ;
202203 }
203204 set
@@ -211,8 +212,8 @@ public static string TypeAttr
211212 {
212213 get
213214 {
214- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeAttr : null )
215- ?? sTypeAttr
215+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeAttr : null )
216+ ?? sTypeAttr
216217 ?? JsWriter . TypeAttr ;
217218 }
218219 set
@@ -229,8 +230,8 @@ internal static string JsonTypeAttrInObject
229230 {
230231 get
231232 {
232- return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsonTypeAttrInObject : null )
233- ?? sJsonTypeAttrInObject
233+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsonTypeAttrInObject : null )
234+ ?? sJsonTypeAttrInObject
234235 ?? defaultJsonTypeAttrInObject ;
235236 }
236237 set
@@ -245,8 +246,8 @@ internal static string JsvTypeAttrInObject
245246 {
246247 get
247248 {
248- return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsvTypeAttrInObject : null )
249- ?? sJsvTypeAttrInObject
249+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsvTypeAttrInObject : null )
250+ ?? sJsvTypeAttrInObject
250251 ?? defaultJsvTypeAttrInObject ;
251252 }
252253 set
@@ -260,8 +261,8 @@ public static Func<Type, string> TypeWriter
260261 {
261262 get
262263 {
263- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeWriter : null )
264- ?? sTypeWriter
264+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeWriter : null )
265+ ?? sTypeWriter
265266 ?? AssemblyUtils . WriteType ;
266267 }
267268 set
@@ -275,8 +276,8 @@ public static Func<string, Type> TypeFinder
275276 {
276277 get
277278 {
278- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeFinder : null )
279- ?? sTypeFinder
279+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeFinder : null )
280+ ?? sTypeFinder
280281 ?? AssemblyUtils . FindType ;
281282 }
282283 set
@@ -290,8 +291,8 @@ public static DateHandler DateHandler
290291 {
291292 get
292293 {
293- return ( JsConfigScope . Current != null ? JsConfigScope . Current . DateHandler : null )
294- ?? sDateHandler
294+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . DateHandler : null )
295+ ?? sDateHandler
295296 ?? DateHandler . TimestampOffset ;
296297 }
297298 set
@@ -331,8 +332,8 @@ public static bool EmitCamelCaseNames
331332 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
332333 get
333334 {
334- return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitCamelCaseNames : null )
335- ?? sEmitCamelCaseNames
335+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitCamelCaseNames : null )
336+ ?? sEmitCamelCaseNames
336337 ?? false ;
337338 }
338339 set
@@ -351,8 +352,8 @@ public static bool EmitLowercaseUnderscoreNames
351352 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
352353 get
353354 {
354- return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitLowercaseUnderscoreNames : null )
355- ?? sEmitLowercaseUnderscoreNames
355+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitLowercaseUnderscoreNames : null )
356+ ?? sEmitLowercaseUnderscoreNames
356357 ?? false ;
357358 }
358359 set
@@ -391,8 +392,8 @@ public static bool ThrowOnDeserializationError
391392 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
392393 get
393394 {
394- return ( JsConfigScope . Current != null ? JsConfigScope . Current . ThrowOnDeserializationError : null )
395- ?? sThrowOnDeserializationError
395+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ThrowOnDeserializationError : null )
396+ ?? sThrowOnDeserializationError
396397 ?? false ;
397398 }
398399 set
@@ -410,8 +411,8 @@ public static bool AlwaysUseUtc
410411 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
411412 get
412413 {
413- return ( JsConfigScope . Current != null ? JsConfigScope . Current . AlwaysUseUtc : null )
414- ?? sAlwaysUseUtc
414+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . AlwaysUseUtc : null )
415+ ?? sAlwaysUseUtc
415416 ?? false ;
416417 }
417418 set
@@ -490,8 +491,8 @@ public static bool PreferInterfaces
490491 {
491492 get
492493 {
493- return ( JsConfigScope . Current != null ? JsConfigScope . Current . PreferInterfaces : null )
494- ?? sPreferInterfaces
494+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . PreferInterfaces : null )
495+ ?? sPreferInterfaces
495496 ?? false ;
496497 }
497498 set
@@ -622,7 +623,7 @@ public static void Reset()
622623
623624 sModelFactory = ReflectionExtensions . GetConstructorMethodToCache ;
624625 sTryToParsePrimitiveTypeValues = null ;
625- sTryToParseNumericType = null ;
626+ sTryToParseNumericType = null ;
626627 sConvertObjectTypesIntoStringDictionary = null ;
627628 sIncludeNullValues = null ;
628629 sExcludeTypeInfo = null ;
@@ -637,7 +638,7 @@ public static void Reset()
637638 sJsvTypeAttrInObject = null ;
638639 sTypeWriter = null ;
639640 sTypeFinder = null ;
640- sTreatEnumAsInteger = null ;
641+ sTreatEnumAsInteger = null ;
641642 sAlwaysUseUtc = null ;
642643 sAssumeUtc = null ;
643644 sAppendUtcOffset = null ;
@@ -650,7 +651,8 @@ public static void Reset()
650651 sExcludePropertyReferences = null ;
651652 sExcludeTypes = new HashSet < Type > { typeof ( Stream ) } ;
652653 __uniqueTypes = new HashSet < Type > ( ) ;
653- sMaxDepth = 50 ;
654+ sMaxDepth = 50 ;
655+ PlatformExtensions . ClearRuntimeAttributes ( ) ;
654656 }
655657
656658 static void Reset ( Type cachesForType )
@@ -721,7 +723,7 @@ public static Func<T, string> SerializeFn
721723 JsConfig . HasSerializeFn . Add ( typeof ( T ) ) ;
722724 else
723725 JsConfig . HasSerializeFn . Remove ( typeof ( T ) ) ;
724-
726+
725727 ClearFnCaches ( ) ;
726728 }
727729 }
@@ -824,7 +826,7 @@ public static void WriteFn<TSerializer>(TextWriter writer, object obj)
824826 else if ( SerializeFn != null )
825827 {
826828 var serializer = JsWriter . GetTypeSerializer < TSerializer > ( ) ;
827- serializer . WriteString ( writer , SerializeFn ( ( T ) obj ) ) ;
829+ serializer . WriteString ( writer , SerializeFn ( ( T ) obj ) ) ;
828830 }
829831 else
830832 {
@@ -849,7 +851,7 @@ internal static object ParseFn(ITypeSerializer serializer, string str)
849851 return DeSerializeFn ( serializer . UnescapeString ( str ) ) ;
850852 }
851853 }
852-
854+
853855 internal static void ClearFnCaches ( )
854856 {
855857 typeof ( JsonWriter < > ) . MakeGenericType ( new [ ] { typeof ( T ) } ) . InvokeReset ( ) ;
@@ -862,7 +864,7 @@ public static void Reset()
862864 DeSerializeFn = null ;
863865 ExcludePropertyNames = null ;
864866 EmitCamelCaseNames = EmitLowercaseUnderscoreNames = IncludeTypeInfo = ExcludeTypeInfo = null ;
865- }
867+ }
866868 }
867869
868870 public enum PropertyConvention
0 commit comments