@@ -22,20 +22,20 @@ public partial class RecommendationsHit : AbstractSchema
2222{
2323 /// <summary>
2424 /// Initializes a new instance of the RecommendationsHit class
25- /// with a RecommendHit
25+ /// with a TrendingFacetHit
2626 /// </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 )
2929 {
3030 ActualInstance = actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
3131 }
3232
3333 /// <summary>
3434 /// Initializes a new instance of the RecommendationsHit class
35- /// with a TrendingFacetHit
35+ /// with a RecommendHit
3636 /// </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 )
3939 {
4040 ActualInstance = actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
4141 }
@@ -47,42 +47,42 @@ public RecommendationsHit(TrendingFacetHit actualInstance)
4747 public sealed override object ActualInstance { get ; set ; }
4848
4949 /// <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 `,
5151 /// the InvalidClassException will be thrown
5252 /// </summary>
53- /// <returns>An instance of RecommendHit </returns>
54- public RecommendHit AsRecommendHit ( )
53+ /// <returns>An instance of TrendingFacetHit </returns>
54+ public TrendingFacetHit AsTrendingFacetHit ( )
5555 {
56- return ( RecommendHit ) ActualInstance ;
56+ return ( TrendingFacetHit ) ActualInstance ;
5757 }
5858
5959 /// <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 `,
6161 /// the InvalidClassException will be thrown
6262 /// </summary>
63- /// <returns>An instance of TrendingFacetHit </returns>
64- public TrendingFacetHit AsTrendingFacetHit ( )
63+ /// <returns>An instance of RecommendHit </returns>
64+ public RecommendHit AsRecommendHit ( )
6565 {
66- return ( TrendingFacetHit ) ActualInstance ;
66+ return ( RecommendHit ) ActualInstance ;
6767 }
6868
6969
7070 /// <summary>
71- /// Check if the actual instance is of `RecommendHit ` type.
71+ /// Check if the actual instance is of `TrendingFacetHit ` type.
7272 /// </summary>
7373 /// <returns>Whether or not the instance is the type</returns>
74- public bool IsRecommendHit ( )
74+ public bool IsTrendingFacetHit ( )
7575 {
76- return ActualInstance . GetType ( ) == typeof ( RecommendHit ) ;
76+ return ActualInstance . GetType ( ) == typeof ( TrendingFacetHit ) ;
7777 }
7878
7979 /// <summary>
80- /// Check if the actual instance is of `TrendingFacetHit ` type.
80+ /// Check if the actual instance is of `RecommendHit ` type.
8181 /// </summary>
8282 /// <returns>Whether or not the instance is the type</returns>
83- public bool IsTrendingFacetHit ( )
83+ public bool IsRecommendHit ( )
8484 {
85- return ActualInstance . GetType ( ) == typeof ( TrendingFacetHit ) ;
85+ return ActualInstance . GetType ( ) == typeof ( RecommendHit ) ;
8686 }
8787
8888 /// <summary>
@@ -169,28 +169,28 @@ public override RecommendationsHit Read(ref Utf8JsonReader reader, Type typeToCo
169169 {
170170 var jsonDocument = JsonDocument . ParseValue ( ref reader ) ;
171171 var root = jsonDocument . RootElement ;
172- if ( root . ValueKind == JsonValueKind . Object )
172+ if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "facetName" , out _ ) && root . TryGetProperty ( "facetValue" , out _ ) )
173173 {
174174 try
175175 {
176- return new RecommendationsHit ( jsonDocument . Deserialize < RecommendHit > ( JsonConfig . Options ) ) ;
176+ return new RecommendationsHit ( jsonDocument . Deserialize < TrendingFacetHit > ( JsonConfig . Options ) ) ;
177177 }
178178 catch ( Exception exception )
179179 {
180180 // 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 } ") ;
182182 }
183183 }
184184 if ( root . ValueKind == JsonValueKind . Object )
185185 {
186186 try
187187 {
188- return new RecommendationsHit ( jsonDocument . Deserialize < TrendingFacetHit > ( JsonConfig . Options ) ) ;
188+ return new RecommendationsHit ( jsonDocument . Deserialize < RecommendHit > ( JsonConfig . Options ) ) ;
189189 }
190190 catch ( Exception exception )
191191 {
192192 // 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 } ") ;
194194 }
195195 }
196196 throw new InvalidDataException ( $ "The JSON string cannot be deserialized into any schema defined.") ;
0 commit comments