@@ -80,6 +80,16 @@ public AuthInputPartial(AuthAlgoliaInsightsPartial actualInstance)
80
80
ActualInstance = actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
81
81
}
82
82
83
+ /// <summary>
84
+ /// Initializes a new instance of the AuthInputPartial class
85
+ /// with a Dictionary{string, string}
86
+ /// </summary>
87
+ /// <param name="actualInstance">An instance of Dictionary<string, string>.</param>
88
+ public AuthInputPartial ( Dictionary < string , string > actualInstance )
89
+ {
90
+ ActualInstance = actualInstance ;
91
+ }
92
+
83
93
84
94
/// <summary>
85
95
/// Gets or Sets ActualInstance
@@ -146,6 +156,16 @@ public AuthAlgoliaInsightsPartial AsAuthAlgoliaInsightsPartial()
146
156
return ( AuthAlgoliaInsightsPartial ) ActualInstance ;
147
157
}
148
158
159
+ /// <summary>
160
+ /// Get the actual instance of `Dictionary{string, string}`. If the actual instance is not `Dictionary{string, string}`,
161
+ /// the InvalidClassException will be thrown
162
+ /// </summary>
163
+ /// <returns>An instance of Dictionary<string, string></returns>
164
+ public Dictionary < string , string > AsDictionaryString ( )
165
+ {
166
+ return ( Dictionary < string , string > ) ActualInstance ;
167
+ }
168
+
149
169
150
170
/// <summary>
151
171
/// Check if the actual instance is of `AuthGoogleServiceAccountPartial` type.
@@ -201,6 +221,15 @@ public bool IsAuthAlgoliaInsightsPartial()
201
221
return ActualInstance . GetType ( ) == typeof ( AuthAlgoliaInsightsPartial ) ;
202
222
}
203
223
224
+ /// <summary>
225
+ /// Check if the actual instance is of `Dictionary{string, string}` type.
226
+ /// </summary>
227
+ /// <returns>Whether or not the instance is the type</returns>
228
+ public bool IsDictionaryString ( )
229
+ {
230
+ return ActualInstance . GetType ( ) == typeof ( Dictionary < string , string > ) ;
231
+ }
232
+
204
233
/// <summary>
205
234
/// Returns the string presentation of the object
206
235
/// </summary>
@@ -357,6 +386,18 @@ public override AuthInputPartial Read(ref Utf8JsonReader reader, Type typeToConv
357
386
System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into AuthAlgoliaInsightsPartial: { exception } ") ;
358
387
}
359
388
}
389
+ if ( root . ValueKind == JsonValueKind . Object )
390
+ {
391
+ try
392
+ {
393
+ return new AuthInputPartial ( jsonDocument . Deserialize < Dictionary < string , string > > ( JsonConfig . Options ) ) ;
394
+ }
395
+ catch ( Exception exception )
396
+ {
397
+ // deserialization failed, try the next one
398
+ System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into Dictionary<string, string>: { exception } ") ;
399
+ }
400
+ }
360
401
throw new InvalidDataException ( $ "The JSON string cannot be deserialized into any schema defined.") ;
361
402
}
362
403
0 commit comments