@@ -22,20 +22,20 @@ public partial class RecommendationsHit : AbstractSchema
22
22
{
23
23
/// <summary>
24
24
/// Initializes a new instance of the RecommendationsHit class
25
- /// with a RecommendHit
25
+ /// with a TrendingFacetHit
26
26
/// </summary>
27
- /// <param name="actualInstance">An instance of RecommendHit .</param>
28
- public RecommendationsHit ( RecommendHit actualInstance )
27
+ /// <param name="actualInstance">An instance of TrendingFacetHit .</param>
28
+ public RecommendationsHit ( TrendingFacetHit actualInstance )
29
29
{
30
30
ActualInstance = actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
31
31
}
32
32
33
33
/// <summary>
34
34
/// Initializes a new instance of the RecommendationsHit class
35
- /// with a TrendingFacetHit
35
+ /// with a RecommendHit
36
36
/// </summary>
37
- /// <param name="actualInstance">An instance of TrendingFacetHit .</param>
38
- public RecommendationsHit ( TrendingFacetHit actualInstance )
37
+ /// <param name="actualInstance">An instance of RecommendHit .</param>
38
+ public RecommendationsHit ( RecommendHit actualInstance )
39
39
{
40
40
ActualInstance = actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
41
41
}
@@ -47,42 +47,42 @@ public RecommendationsHit(TrendingFacetHit actualInstance)
47
47
public sealed override object ActualInstance { get ; set ; }
48
48
49
49
/// <summary>
50
- /// Get the actual instance of `RecommendHit `. If the actual instance is not `RecommendHit `,
50
+ /// Get the actual instance of `TrendingFacetHit `. If the actual instance is not `TrendingFacetHit `,
51
51
/// the InvalidClassException will be thrown
52
52
/// </summary>
53
- /// <returns>An instance of RecommendHit </returns>
54
- public RecommendHit AsRecommendHit ( )
53
+ /// <returns>An instance of TrendingFacetHit </returns>
54
+ public TrendingFacetHit AsTrendingFacetHit ( )
55
55
{
56
- return ( RecommendHit ) ActualInstance ;
56
+ return ( TrendingFacetHit ) ActualInstance ;
57
57
}
58
58
59
59
/// <summary>
60
- /// Get the actual instance of `TrendingFacetHit `. If the actual instance is not `TrendingFacetHit `,
60
+ /// Get the actual instance of `RecommendHit `. If the actual instance is not `RecommendHit `,
61
61
/// the InvalidClassException will be thrown
62
62
/// </summary>
63
- /// <returns>An instance of TrendingFacetHit </returns>
64
- public TrendingFacetHit AsTrendingFacetHit ( )
63
+ /// <returns>An instance of RecommendHit </returns>
64
+ public RecommendHit AsRecommendHit ( )
65
65
{
66
- return ( TrendingFacetHit ) ActualInstance ;
66
+ return ( RecommendHit ) ActualInstance ;
67
67
}
68
68
69
69
70
70
/// <summary>
71
- /// Check if the actual instance is of `RecommendHit ` type.
71
+ /// Check if the actual instance is of `TrendingFacetHit ` type.
72
72
/// </summary>
73
73
/// <returns>Whether or not the instance is the type</returns>
74
- public bool IsRecommendHit ( )
74
+ public bool IsTrendingFacetHit ( )
75
75
{
76
- return ActualInstance . GetType ( ) == typeof ( RecommendHit ) ;
76
+ return ActualInstance . GetType ( ) == typeof ( TrendingFacetHit ) ;
77
77
}
78
78
79
79
/// <summary>
80
- /// Check if the actual instance is of `TrendingFacetHit ` type.
80
+ /// Check if the actual instance is of `RecommendHit ` type.
81
81
/// </summary>
82
82
/// <returns>Whether or not the instance is the type</returns>
83
- public bool IsTrendingFacetHit ( )
83
+ public bool IsRecommendHit ( )
84
84
{
85
- return ActualInstance . GetType ( ) == typeof ( TrendingFacetHit ) ;
85
+ return ActualInstance . GetType ( ) == typeof ( RecommendHit ) ;
86
86
}
87
87
88
88
/// <summary>
@@ -169,28 +169,28 @@ public override RecommendationsHit Read(ref Utf8JsonReader reader, Type typeToCo
169
169
{
170
170
var jsonDocument = JsonDocument . ParseValue ( ref reader ) ;
171
171
var root = jsonDocument . RootElement ;
172
- if ( root . ValueKind == JsonValueKind . Object )
172
+ if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "facetName" , out _ ) && root . TryGetProperty ( "facetValue" , out _ ) )
173
173
{
174
174
try
175
175
{
176
- return new RecommendationsHit ( jsonDocument . Deserialize < RecommendHit > ( JsonConfig . Options ) ) ;
176
+ return new RecommendationsHit ( jsonDocument . Deserialize < TrendingFacetHit > ( JsonConfig . Options ) ) ;
177
177
}
178
178
catch ( Exception exception )
179
179
{
180
180
// deserialization failed, try the next one
181
- System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into RecommendHit : { exception } ") ;
181
+ System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into TrendingFacetHit : { exception } ") ;
182
182
}
183
183
}
184
184
if ( root . ValueKind == JsonValueKind . Object )
185
185
{
186
186
try
187
187
{
188
- return new RecommendationsHit ( jsonDocument . Deserialize < TrendingFacetHit > ( JsonConfig . Options ) ) ;
188
+ return new RecommendationsHit ( jsonDocument . Deserialize < RecommendHit > ( JsonConfig . Options ) ) ;
189
189
}
190
190
catch ( Exception exception )
191
191
{
192
192
// deserialization failed, try the next one
193
- System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into TrendingFacetHit : { exception } ") ;
193
+ System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into RecommendHit : { exception } ") ;
194
194
}
195
195
}
196
196
throw new InvalidDataException ( $ "The JSON string cannot be deserialized into any schema defined.") ;
0 commit comments