本文整理汇总了C#中TweetSharp.TwitterService.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.Deserialize方法的具体用法?C# TwitterService.Deserialize怎么用?C# TwitterService.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.Deserialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: bw_DoWork
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
TwitterService service = new TwitterService(consumerKeyTextBox.Text, consumerSecretTextBox.Text, accessTokenTextBox.Text, accessTokenSecretTextBox.Text);
TwitterUser user = service.VerifyCredentials();
if (service.Response.InnerException != null)
{
TwitterError error = service.Deserialize<TwitterError>(service.Response.Response);
if (!string.IsNullOrEmpty(error.ErrorMessage))
{
e.Result = error; // return the error object on failure
}
else
{
e.Result = null; // err, dunno. return null
}
}
else if (user != null)
{
e.Result = user; // return user object on success
}
else
{
e.Result = null; // unknown error
}
}
示例2: ProcessTweets
private static Action<TwitterStreamArtifact, TwitterResponse> ProcessTweets(TwitterService service)
{
return (tweets, response) =>
{
if (tweets == null)
{
}
else
{
try
{
var status = service.Deserialize<TwitterStatus>(tweets);
if (status.User != null)
{
Console.WriteLine(string.Format("{0}:{1}\n{2}", status.User.ScreenName, status.Text,status.Id));
if(!CurrentGames.ContainsKey(status.User.Id))
{
var twitterThread = new TwitterThread(status.Id, service);
twitterThread.OnStateChange += args => tweetsToSend.Enqueue(args);
CurrentGames.Add(status.User.Id, twitterThread);
}
var thisgame = CurrentGames[status.User.Id];
if(thisgame.IsStarted)
{
var cluelastpattern = @"(\S*$)";
var match = Regex.Match(status.Text, cluelastpattern);
var clue = match.Groups[0].Value;
thisgame.Update(clue,status.Id);
}else
{
var clue = ParseClueFromTweet(status);
thisgame.Start(clue);
}
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine(ex.Message);
Console.ResetColor();
}
}
};
}
示例3: IsFail
bool IsFail(IEnumerable<TwitterStatus> statuses, string sendto, string feedname = "none")
{
var service = new TwitterService();
bool result = false;
string errorMessage = "no error";
if (TwitterWrapper.LastResponse != null && TwitterWrapper.LastResponse.StatusCode == HttpStatusCode.Unauthorized)
{
errorMessage = "401 Unauthorized";
result = true;
}
else
{
if (statuses.Count() == 1)
{
TwitterStatus mention = statuses.First();
if (mention.Id == 0)
{
errorMessage = "Unsuccessfull deserialization";
result = true;
}
var error = service.Deserialize<TwitterError>(statuses.First());
if (!string.IsNullOrEmpty(error.ErrorMessage))
{
errorMessage = error.ErrorMessage;
result = true;
}
}
}
if (result)
{
BotMethods.SendMessage(SendType.Message, sendto, "Error on feed '{0}': {1}".Fill(feedname, errorMessage));
}
return result;
}