try
{
var resultElm = this.Element.Element("tweet_results")?.Element("result") ?? throw CreateParseError();
- var tweetElm = resultElm.Element("__typename")?.Value switch
- {
- "Tweet" => resultElm,
- "TweetWithVisibilityResults" => resultElm.Element("tweet") ?? throw CreateParseError(),
- _ => throw CreateParseError(),
- };
-
- return this.ParseTweet(tweetElm);
+ return this.ParseTweetUnion(resultElm);
}
catch (WebApiException ex)
{
}
}
+ private TwitterStatus ParseTweetUnion(XElement tweetUnionElm)
+ {
+ var tweetElm = tweetUnionElm.Element("__typename")?.Value switch
+ {
+ "Tweet" => tweetUnionElm,
+ "TweetWithVisibilityResults" => tweetUnionElm.Element("tweet") ?? throw CreateParseError(),
+ _ => throw CreateParseError(),
+ };
+
+ return this.ParseTweet(tweetElm);
+ }
+
private TwitterStatus ParseTweet(XElement tweetElm)
{
var tweetLegacyElm = tweetElm.Element("legacy") ?? throw CreateParseError();
ScreenName = GetText(userLegacyElm, "screen_name"),
Protected = GetTextOrNull(userLegacyElm, "protected") == "true",
},
- RetweetedStatus = retweetedTweetElm != null ? this.ParseTweet(retweetedTweetElm) : null,
+ RetweetedStatus = retweetedTweetElm != null ? this.ParseTweetUnion(retweetedTweetElm) : null,
};
}