@@ -31,6 +31,90 @@ public static JsConfigScope BeginScope()
3131 return new JsConfigScope ( ) ;
3232 }
3333
34+ public static JsConfigScope CreateScope ( string config )
35+ {
36+ if ( string . IsNullOrEmpty ( config ) )
37+ return null ;
38+
39+ var scope = BeginScope ( ) ;
40+ var items = config . Split ( ',' ) ;
41+ foreach ( var item in items )
42+ {
43+ var parts = item . SplitOnFirst ( ':' ) ;
44+ var key = parts [ 0 ] . ToLower ( ) ;
45+ var boolValue = parts . Length == 1 || ( parts [ 1 ] . ToLower ( ) != "false" && parts [ 1 ] != "0" ) ;
46+
47+ switch ( key )
48+ {
49+ case "convertobjecttypesintostringdictionary" :
50+ scope . ConvertObjectTypesIntoStringDictionary = boolValue ;
51+ break ;
52+ case "trytoparseprimitivetypevalues" :
53+ scope . TryToParsePrimitiveTypeValues = boolValue ;
54+ break ;
55+ case "trytoparsenumerictype" :
56+ scope . TryToParseNumericType = boolValue ;
57+ break ;
58+ case "excludedefaultvalues" :
59+ scope . ExcludeDefaultValues = boolValue ;
60+ break ;
61+ case "includenullvalues" :
62+ scope . IncludeNullValues = boolValue ;
63+ break ;
64+ case "includenullvaluesindictionaries" :
65+ scope . IncludeNullValuesInDictionaries = boolValue ;
66+ break ;
67+ case "includedefaultenums" :
68+ scope . IncludeDefaultEnums = boolValue ;
69+ break ;
70+ case "excludetypeinfo" :
71+ scope . ExcludeTypeInfo = boolValue ;
72+ break ;
73+ case "includetypeinfo" :
74+ scope . IncludeTypeInfo = boolValue ;
75+ break ;
76+ case "emitcamelcasenames" :
77+ scope . EmitCamelCaseNames = boolValue ;
78+ break ;
79+ case "emitlowercaseunderscorenames" :
80+ scope . EmitLowercaseUnderscoreNames = boolValue ;
81+ break ;
82+ case "preferinterfaces" :
83+ scope . PreferInterfaces = boolValue ;
84+ break ;
85+ case "throwondeserializationerror" :
86+ scope . ThrowOnDeserializationError = boolValue ;
87+ break ;
88+ case "treatenumasinteger" :
89+ scope . TreatEnumAsInteger = boolValue ;
90+ break ;
91+ case "skipdatetimeconversion" :
92+ scope . SkipDateTimeConversion = boolValue ;
93+ break ;
94+ case "alwaysuseutc" :
95+ scope . AlwaysUseUtc = boolValue ;
96+ break ;
97+ case "assumeutc" :
98+ scope . AssumeUtc = boolValue ;
99+ break ;
100+ case "appendutcoffset" :
101+ scope . AppendUtcOffset = boolValue ;
102+ break ;
103+ case "escapeunicode" :
104+ scope . EscapeUnicode = boolValue ;
105+ break ;
106+ case "includepublicfields" :
107+ scope . IncludePublicFields = boolValue ;
108+ break ;
109+ case "reuseStringBuffer" :
110+ scope . ReuseStringBuffer = boolValue ;
111+ break ;
112+ }
113+ }
114+
115+ return scope ;
116+ }
117+
34118 public static JsConfigScope With (
35119 bool ? convertObjectTypesIntoStringDictionary = null ,
36120 bool ? tryToParsePrimitiveTypeValues = null ,
0 commit comments