@@ -29,7 +29,7 @@ public static JsConfigScope BeginScope()
29
29
public static JsConfigScope With (
30
30
bool ? convertObjectTypesIntoStringDictionary = null ,
31
31
bool ? tryToParsePrimitiveTypeValues = null ,
32
- bool ? tryToParseNumericType = null ,
32
+ bool ? tryToParseNumericType = null ,
33
33
bool ? includeNullValues = null ,
34
34
bool ? includeDefaultEnums = null ,
35
35
bool ? excludeTypeInfo = null ,
@@ -44,7 +44,7 @@ public static JsConfigScope With(
44
44
string typeAttr = null ,
45
45
Func < Type , string > typeWriter = null ,
46
46
Func < string , Type > typeFinder = null ,
47
- bool ? treatEnumAsInteger = null ,
47
+ bool ? treatEnumAsInteger = null ,
48
48
bool ? alwaysUseUtc = null ,
49
49
bool ? assumeUtc = null ,
50
50
bool ? appendUtcOffset = null ,
@@ -55,7 +55,8 @@ public static JsConfigScope With(
55
55
EmptyCtorFactoryDelegate modelFactory = null ,
56
56
string [ ] excludePropertyReferences = null )
57
57
{
58
- return new JsConfigScope {
58
+ return new JsConfigScope
59
+ {
59
60
ConvertObjectTypesIntoStringDictionary = convertObjectTypesIntoStringDictionary ?? sConvertObjectTypesIntoStringDictionary ,
60
61
TryToParsePrimitiveTypeValues = tryToParsePrimitiveTypeValues ?? sTryToParsePrimitiveTypeValues ,
61
62
TryToParseNumericType = tryToParseNumericType ?? sTryToParseNumericType ,
@@ -91,8 +92,8 @@ public static bool ConvertObjectTypesIntoStringDictionary
91
92
{
92
93
get
93
94
{
94
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . ConvertObjectTypesIntoStringDictionary : null )
95
- ?? sConvertObjectTypesIntoStringDictionary
95
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ConvertObjectTypesIntoStringDictionary : null )
96
+ ?? sConvertObjectTypesIntoStringDictionary
96
97
?? false ;
97
98
}
98
99
set
@@ -106,8 +107,8 @@ public static bool TryToParsePrimitiveTypeValues
106
107
{
107
108
get
108
109
{
109
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParsePrimitiveTypeValues : null )
110
- ?? sTryToParsePrimitiveTypeValues
110
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TryToParsePrimitiveTypeValues : null )
111
+ ?? sTryToParsePrimitiveTypeValues
111
112
?? false ;
112
113
}
113
114
set
@@ -116,20 +117,20 @@ public static bool TryToParsePrimitiveTypeValues
116
117
}
117
118
}
118
119
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
+ }
133
134
134
135
private static bool ? sIncludeNullValues ;
135
136
public static bool IncludeNullValues
@@ -166,8 +167,8 @@ public static bool TreatEnumAsInteger
166
167
{
167
168
get
168
169
{
169
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TreatEnumAsInteger : null )
170
- ?? sTreatEnumAsInteger
170
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TreatEnumAsInteger : null )
171
+ ?? sTreatEnumAsInteger
171
172
?? false ;
172
173
}
173
174
set
@@ -181,8 +182,8 @@ public static bool ExcludeTypeInfo
181
182
{
182
183
get
183
184
{
184
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . ExcludeTypeInfo : null )
185
- ?? sExcludeTypeInfo
185
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ExcludeTypeInfo : null )
186
+ ?? sExcludeTypeInfo
186
187
?? false ;
187
188
}
188
189
set
@@ -196,8 +197,8 @@ public static bool IncludeTypeInfo
196
197
{
197
198
get
198
199
{
199
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . IncludeTypeInfo : null )
200
- ?? sIncludeTypeInfo
200
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . IncludeTypeInfo : null )
201
+ ?? sIncludeTypeInfo
201
202
?? false ;
202
203
}
203
204
set
@@ -211,8 +212,8 @@ public static string TypeAttr
211
212
{
212
213
get
213
214
{
214
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeAttr : null )
215
- ?? sTypeAttr
215
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeAttr : null )
216
+ ?? sTypeAttr
216
217
?? JsWriter . TypeAttr ;
217
218
}
218
219
set
@@ -229,8 +230,8 @@ internal static string JsonTypeAttrInObject
229
230
{
230
231
get
231
232
{
232
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsonTypeAttrInObject : null )
233
- ?? sJsonTypeAttrInObject
233
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsonTypeAttrInObject : null )
234
+ ?? sJsonTypeAttrInObject
234
235
?? defaultJsonTypeAttrInObject ;
235
236
}
236
237
set
@@ -245,8 +246,8 @@ internal static string JsvTypeAttrInObject
245
246
{
246
247
get
247
248
{
248
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsvTypeAttrInObject : null )
249
- ?? sJsvTypeAttrInObject
249
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . JsvTypeAttrInObject : null )
250
+ ?? sJsvTypeAttrInObject
250
251
?? defaultJsvTypeAttrInObject ;
251
252
}
252
253
set
@@ -260,8 +261,8 @@ public static Func<Type, string> TypeWriter
260
261
{
261
262
get
262
263
{
263
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeWriter : null )
264
- ?? sTypeWriter
264
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeWriter : null )
265
+ ?? sTypeWriter
265
266
?? AssemblyUtils . WriteType ;
266
267
}
267
268
set
@@ -275,8 +276,8 @@ public static Func<string, Type> TypeFinder
275
276
{
276
277
get
277
278
{
278
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeFinder : null )
279
- ?? sTypeFinder
279
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . TypeFinder : null )
280
+ ?? sTypeFinder
280
281
?? AssemblyUtils . FindType ;
281
282
}
282
283
set
@@ -290,8 +291,8 @@ public static DateHandler DateHandler
290
291
{
291
292
get
292
293
{
293
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . DateHandler : null )
294
- ?? sDateHandler
294
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . DateHandler : null )
295
+ ?? sDateHandler
295
296
?? DateHandler . TimestampOffset ;
296
297
}
297
298
set
@@ -331,8 +332,8 @@ public static bool EmitCamelCaseNames
331
332
// obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
332
333
get
333
334
{
334
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitCamelCaseNames : null )
335
- ?? sEmitCamelCaseNames
335
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitCamelCaseNames : null )
336
+ ?? sEmitCamelCaseNames
336
337
?? false ;
337
338
}
338
339
set
@@ -351,8 +352,8 @@ public static bool EmitLowercaseUnderscoreNames
351
352
// obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
352
353
get
353
354
{
354
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitLowercaseUnderscoreNames : null )
355
- ?? sEmitLowercaseUnderscoreNames
355
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . EmitLowercaseUnderscoreNames : null )
356
+ ?? sEmitLowercaseUnderscoreNames
356
357
?? false ;
357
358
}
358
359
set
@@ -391,8 +392,8 @@ public static bool ThrowOnDeserializationError
391
392
// obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
392
393
get
393
394
{
394
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . ThrowOnDeserializationError : null )
395
- ?? sThrowOnDeserializationError
395
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . ThrowOnDeserializationError : null )
396
+ ?? sThrowOnDeserializationError
396
397
?? false ;
397
398
}
398
399
set
@@ -410,8 +411,8 @@ public static bool AlwaysUseUtc
410
411
// obeying the use of ThreadStatic, but allowing for setting JsConfig once as is the normal case
411
412
get
412
413
{
413
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . AlwaysUseUtc : null )
414
- ?? sAlwaysUseUtc
414
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . AlwaysUseUtc : null )
415
+ ?? sAlwaysUseUtc
415
416
?? false ;
416
417
}
417
418
set
@@ -490,8 +491,8 @@ public static bool PreferInterfaces
490
491
{
491
492
get
492
493
{
493
- return ( JsConfigScope . Current != null ? JsConfigScope . Current . PreferInterfaces : null )
494
- ?? sPreferInterfaces
494
+ return ( JsConfigScope . Current != null ? JsConfigScope . Current . PreferInterfaces : null )
495
+ ?? sPreferInterfaces
495
496
?? false ;
496
497
}
497
498
set
@@ -622,7 +623,7 @@ public static void Reset()
622
623
623
624
sModelFactory = ReflectionExtensions . GetConstructorMethodToCache ;
624
625
sTryToParsePrimitiveTypeValues = null ;
625
- sTryToParseNumericType = null ;
626
+ sTryToParseNumericType = null ;
626
627
sConvertObjectTypesIntoStringDictionary = null ;
627
628
sIncludeNullValues = null ;
628
629
sExcludeTypeInfo = null ;
@@ -637,7 +638,7 @@ public static void Reset()
637
638
sJsvTypeAttrInObject = null ;
638
639
sTypeWriter = null ;
639
640
sTypeFinder = null ;
640
- sTreatEnumAsInteger = null ;
641
+ sTreatEnumAsInteger = null ;
641
642
sAlwaysUseUtc = null ;
642
643
sAssumeUtc = null ;
643
644
sAppendUtcOffset = null ;
@@ -650,7 +651,8 @@ public static void Reset()
650
651
sExcludePropertyReferences = null ;
651
652
sExcludeTypes = new HashSet < Type > { typeof ( Stream ) } ;
652
653
__uniqueTypes = new HashSet < Type > ( ) ;
653
- sMaxDepth = 50 ;
654
+ sMaxDepth = 50 ;
655
+ PlatformExtensions . ClearRuntimeAttributes ( ) ;
654
656
}
655
657
656
658
static void Reset ( Type cachesForType )
@@ -721,7 +723,7 @@ public static Func<T, string> SerializeFn
721
723
JsConfig . HasSerializeFn . Add ( typeof ( T ) ) ;
722
724
else
723
725
JsConfig . HasSerializeFn . Remove ( typeof ( T ) ) ;
724
-
726
+
725
727
ClearFnCaches ( ) ;
726
728
}
727
729
}
@@ -824,7 +826,7 @@ public static void WriteFn<TSerializer>(TextWriter writer, object obj)
824
826
else if ( SerializeFn != null )
825
827
{
826
828
var serializer = JsWriter . GetTypeSerializer < TSerializer > ( ) ;
827
- serializer . WriteString ( writer , SerializeFn ( ( T ) obj ) ) ;
829
+ serializer . WriteString ( writer , SerializeFn ( ( T ) obj ) ) ;
828
830
}
829
831
else
830
832
{
@@ -849,7 +851,7 @@ internal static object ParseFn(ITypeSerializer serializer, string str)
849
851
return DeSerializeFn ( serializer . UnescapeString ( str ) ) ;
850
852
}
851
853
}
852
-
854
+
853
855
internal static void ClearFnCaches ( )
854
856
{
855
857
typeof ( JsonWriter < > ) . MakeGenericType ( new [ ] { typeof ( T ) } ) . InvokeReset ( ) ;
@@ -862,7 +864,7 @@ public static void Reset()
862
864
DeSerializeFn = null ;
863
865
ExcludePropertyNames = null ;
864
866
EmitCamelCaseNames = EmitLowercaseUnderscoreNames = IncludeTypeInfo = ExcludeTypeInfo = null ;
865
- }
867
+ }
866
868
}
867
869
868
870
public enum PropertyConvention
0 commit comments