@@ -23,14 +23,22 @@ static JsConfig()
2323 Reset ( ) ;
2424 }
2525
26+ public static JsConfigScope BeginScope ( )
27+ {
28+ return new JsConfigScope ( ) ;
29+ }
30+
2631 [ ThreadStatic ]
2732 private static bool ? tsConvertObjectTypesIntoStringDictionary ;
2833 private static bool ? sConvertObjectTypesIntoStringDictionary ;
2934 public static bool ConvertObjectTypesIntoStringDictionary
3035 {
3136 get
3237 {
33- return tsConvertObjectTypesIntoStringDictionary ?? sConvertObjectTypesIntoStringDictionary ?? false ;
38+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ConvertObjectTypesIntoStringDictionary : null )
39+ ?? tsConvertObjectTypesIntoStringDictionary
40+ ?? sConvertObjectTypesIntoStringDictionary
41+ ?? false ;
3442 }
3543 set
3644 {
@@ -46,7 +54,10 @@ public static bool TryToParsePrimitiveTypeValues
4654 {
4755 get
4856 {
49- return tsTryToParsePrimitiveTypeValues ?? sTryToParsePrimitiveTypeValues ?? false ;
57+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParsePrimitiveTypeValues : null )
58+ ?? tsTryToParsePrimitiveTypeValues
59+ ?? sTryToParsePrimitiveTypeValues
60+ ?? false ;
5061 }
5162 set
5263 {
@@ -62,7 +73,10 @@ public static bool IncludeNullValues
6273 {
6374 get
6475 {
65- return tsIncludeNullValues ?? sIncludeNullValues ?? false ;
76+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . IncludeNullValues : null )
77+ ?? tsIncludeNullValues
78+ ?? sIncludeNullValues
79+ ?? false ;
6680 }
6781 set
6882 {
@@ -78,7 +92,10 @@ public static bool TreatEnumAsInteger
7892 {
7993 get
8094 {
81- return tsTreatEnumAsInteger ?? sTreatEnumAsInteger ?? false ;
95+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TreatEnumAsInteger : null )
96+ ?? tsTreatEnumAsInteger
97+ ?? sTreatEnumAsInteger
98+ ?? false ;
8299 }
83100 set
84101 {
@@ -94,7 +111,10 @@ public static bool ExcludeTypeInfo
94111 {
95112 get
96113 {
97- return tsExcludeTypeInfo ?? sExcludeTypeInfo ?? false ;
114+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ExcludeTypeInfo : null )
115+ ?? tsExcludeTypeInfo
116+ ?? sExcludeTypeInfo
117+ ?? false ;
98118 }
99119 set
100120 {
@@ -110,7 +130,10 @@ public static bool IncludeTypeInfo
110130 {
111131 get
112132 {
113- return tsForceTypeInfo ?? sForceTypeInfo ?? false ;
133+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . IncludeTypeInfo : null )
134+ ?? tsForceTypeInfo
135+ ?? sForceTypeInfo
136+ ?? false ;
114137 }
115138 set
116139 {
@@ -126,7 +149,10 @@ public static string TypeAttr
126149 {
127150 get
128151 {
129- return tsTypeAttr ?? sTypeAttr ?? JsWriter . TypeAttr ;
152+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeAttr : null )
153+ ?? tsTypeAttr
154+ ?? sTypeAttr
155+ ?? JsWriter . TypeAttr ;
130156 }
131157 set
132158 {
@@ -145,7 +171,10 @@ internal static string JsonTypeAttrInObject
145171 {
146172 get
147173 {
148- return tsJsonTypeAttrInObject ?? sJsonTypeAttrInObject ?? defaultJsonTypeAttrInObject ;
174+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsonTypeAttrInObject : null )
175+ ?? tsJsonTypeAttrInObject
176+ ?? sJsonTypeAttrInObject
177+ ?? defaultJsonTypeAttrInObject ;
149178 }
150179 set
151180 {
@@ -162,7 +191,10 @@ internal static string JsvTypeAttrInObject
162191 {
163192 get
164193 {
165- return tsJsvTypeAttrInObject ?? sJsvTypeAttrInObject ?? defaultJsvTypeAttrInObject ;
194+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsvTypeAttrInObject : null )
195+ ?? tsJsvTypeAttrInObject
196+ ?? sJsvTypeAttrInObject
197+ ?? defaultJsvTypeAttrInObject ;
166198 }
167199 set
168200 {
@@ -178,7 +210,10 @@ public static Func<Type, string> TypeWriter
178210 {
179211 get
180212 {
181- return tsTypeWriter ?? sTypeWriter ?? AssemblyUtils . WriteType ;
213+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeWriter : null )
214+ ?? tsTypeWriter
215+ ?? sTypeWriter
216+ ?? AssemblyUtils . WriteType ;
182217 }
183218 set
184219 {
@@ -194,7 +229,10 @@ public static Func<string, Type> TypeFinder
194229 {
195230 get
196231 {
197- return tsTypeFinder ?? sTypeFinder ?? AssemblyUtils . FindType ;
232+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeFinder : null )
233+ ?? tsTypeFinder
234+ ?? sTypeFinder
235+ ?? AssemblyUtils . FindType ;
198236 }
199237 set
200238 {
@@ -210,7 +248,10 @@ public static JsonDateHandler DateHandler
210248 {
211249 get
212250 {
213- return tsDateHandler ?? sDateHandler ?? JsonDateHandler . TimestampOffset ;
251+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . DateHandler : null )
252+ ?? tsDateHandler
253+ ?? sDateHandler
254+ ?? JsonDateHandler . TimestampOffset ;
214255 }
215256 set
216257 {
@@ -238,7 +279,10 @@ public static bool EmitCamelCaseNames
238279 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
239280 get
240281 {
241- return tsEmitCamelCaseNames ?? sEmitCamelCaseNames ?? false ;
282+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitCamelCaseNames : null )
283+ ?? tsEmitCamelCaseNames
284+ ?? sEmitCamelCaseNames
285+ ?? false ;
242286 }
243287 set
244288 {
@@ -259,7 +303,10 @@ public static bool EmitLowercaseUnderscoreNames
259303 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
260304 get
261305 {
262- return tsEmitLowercaseUnderscoreNames ?? sEmitLowercaseUnderscoreNames ?? false ;
306+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitLowercaseUnderscoreNames : null )
307+ ?? tsEmitLowercaseUnderscoreNames
308+ ?? sEmitLowercaseUnderscoreNames
309+ ?? false ;
263310 }
264311 set
265312 {
@@ -304,7 +351,10 @@ public static bool ThrowOnDeserializationError
304351 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
305352 get
306353 {
307- return tsThrowOnDeserializationError ?? sThrowOnDeserializationError ?? false ;
354+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ThrowOnDeserializationError : null )
355+ ?? tsThrowOnDeserializationError
356+ ?? sThrowOnDeserializationError
357+ ?? false ;
308358 }
309359 set
310360 {
@@ -324,7 +374,10 @@ public static bool AlwaysUseUtc
324374 // obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
325375 get
326376 {
327- return tsAlwaysUseUtc ?? sAlwaysUseUtc ?? false ;
377+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . AlwaysUseUtc : null )
378+ ?? tsAlwaysUseUtc
379+ ?? sAlwaysUseUtc
380+ ?? false ;
328381 }
329382 set
330383 {
@@ -347,7 +400,10 @@ public static bool PreferInterfaces
347400 {
348401 get
349402 {
350- return tsPreferInterfaces ?? sPreferInterfaces ?? false ;
403+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . PreferInterfaces : null )
404+ ?? tsPreferInterfaces
405+ ?? sPreferInterfaces
406+ ?? false ;
351407 }
352408 set
353409 {
0 commit comments