本文整理汇总了C#中Tweet类的典型用法代码示例。如果您正苦于以下问题:C# Tweet类的具体用法?C# Tweet怎么用?C# Tweet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tweet类属于命名空间,在下文中一共展示了Tweet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUpSteps
protected override void SetUpSteps()
{
Given("the Refresh Cycle is {0} seconds", RefreshCycle =>
App.Settings.DefaultRefreshCycle =
Int32.Parse(RefreshCycle) * 1000
);
And("Home is shown", () => {
HomePresenter.Load();
OriginalFirstTweet = TweetsShown[0];
});
When("Status is updated", () =>
HomePresenter.TweetService.UpdateStatus(Tweet)
);
And("{0} seconds have passed", WaitTime =>
Thread.Sleep(Convert.ToInt32(WaitTime)*1000)
);
Then("Home should contain the Tweet", () =>
TweetsShown.ToList().ShouldContain(Tweet)
);
And("the Tweet should be shown above the older ones", () => {
TweetsShown.ToList().ShouldContain(Tweet);
TweetsShown.IndexOf(Tweet).ShouldBeLessThan(
TweetsShown.IndexOf(OriginalFirstTweet));}
);
}
示例2: Create
public ActionResult Create(TweetViewModel tweet)
{
if (this.ModelState.IsValid)
{
tweet.AuthorId = this.User.Identity.GetUserId();
var newTweet = new Tweet {AuthorId = tweet.AuthorId, Text = tweet.Text};
this.db.Tweets.Add(newTweet);
this.db.SaveChanges();
// Show Tweet to all followers
var context = GlobalHost.ConnectionManager.GetHubContext<TweeterHub>();
var usernames = this.UserProfile.Followers.Select(f => f.UserName).ToList();
context.Clients.Users(usernames).showTweet(newTweet.Id);
this.TempData["message"] = "Tweet added successfully.";
this.TempData["isMessageSuccess"] = true;
return this.RedirectToAction("Index", "Home");
}
this.TempData["message"] = "There are problem with tweet adding.";
this.TempData["isMessageSuccess"] = false;
this.ViewBag.AuthorId = new SelectList(this.db.Users, "Id", "FullName", tweet.AuthorId);
return this.View("Tweet/_CreateTweetPartial", tweet);
}
示例3: Deserialize
public object Deserialize(JsonValue value, JsonMapper mapper)
{
Tweet tweet = new Tweet();
tweet.ID = value.GetValue<long>("id");
tweet.Text = value.GetValue<string>("text");
JsonValue fromUserValue = value.GetValue("user");
string dateFormat;
if (fromUserValue != null)
{
tweet.FromUser = fromUserValue.GetValue<string>("screen_name");
tweet.FromUserId = fromUserValue.GetValue<long>("id");
tweet.ProfileImageUrl = fromUserValue.GetValue<string>("profile_image_url");
dateFormat = TIMELINE_DATE_FORMAT;
}
else
{
tweet.FromUser = value.GetValue<string>("from_user");
tweet.FromUserId = value.GetValue<long>("from_user_id");
tweet.ProfileImageUrl = value.GetValue<string>("profile_image_url");
dateFormat = SEARCH_DATE_FORMAT;
}
tweet.CreatedAt = JsonUtils.ToDateTime(value.GetValue<string>("created_at"), dateFormat);
tweet.Source = value.GetValue<string>("source");
JsonValue toUserIdValue = value.GetValue("in_reply_to_user_id");
tweet.ToUserId = (toUserIdValue != null) ? toUserIdValue.GetValue<long?>() : null;
JsonValue languageCodeValue = value.GetValue("iso_language_code");
tweet.LanguageCode = (languageCodeValue != null) ? languageCodeValue.GetValue<string>() : null;
JsonValue inReplyToStatusIdValue = value.GetValue("in_reply_to_status_id");
tweet.InReplyToStatusId = ((inReplyToStatusIdValue != null) && !inReplyToStatusIdValue.IsNull) ? inReplyToStatusIdValue.GetValue<long?>() : null;
return tweet;
}
示例4: TweetToHtmlFormatUsernames
public void TweetToHtmlFormatUsernames()
{
var text = "RT @topascz: Test tweet";
var tweet = new Tweet(new TwitterUser(null, null, null, null, null, 0, 0, 0), text, DateTime.MinValue, String.Empty);
Assert.Equal("RT <a href=\"https://www.twitter.com/topascz\">@topascz</a>: Test tweet", tweet.TextToHtmlString().ToString());
}
示例5: Add
// Imitates a queue appending a status at the end of the list
public void Add(Tweet status)
{
if (_tweets.Find(t => status.Id == t.Id) == null)
{
_tweets.Insert(_tweets.Count, status);
}
}
示例6: TweetToHtmlFormatNotLink
public void TweetToHtmlFormatNotLink()
{
var text = "Testing link www.twitter.com";
var tweet = new Tweet(new TwitterUser(null, null, null, null, null, 0, 0, 0), text, DateTime.MinValue, String.Empty);
Assert.Equal("Testing link www.twitter.com", tweet.TextToHtmlString().ToString());
}
示例7: TweetToHtmlFormatNotUsernames
public void TweetToHtmlFormatNotUsernames()
{
var text = "Some email [email protected] @123";
var tweet = new Tweet(new TwitterUser(null, null, null, null, null, 0, 0, 0), text, DateTime.MinValue, String.Empty);
Assert.Equal("Some email [email protected] @123", tweet.TextToHtmlString().ToString());
}
示例8: TweetToHtmlFormatNotHashtags
public void TweetToHtmlFormatNotHashtags()
{
var text = "Next test#test";
var tweet = new Tweet(new TwitterUser(null, null, null, null, null, 0, 0, 0), text, DateTime.MinValue, String.Empty);
Assert.Equal("Next test#test", tweet.TextToHtmlString().ToString());
}
示例9: TweetToHtmlFormatHttpsLink
public void TweetToHtmlFormatHttpsLink()
{
var text = "Testing link https://www.twitter.com";
var tweet = new Tweet(new TwitterUser(null, null, null, null, null, 0, 0, 0), text, DateTime.MinValue, String.Empty);
Assert.Equal("Testing link <a href=\"https://www.twitter.com\">https://www.twitter.com</a>", tweet.TextToHtmlString().ToString());
}
示例10: TweetToHtmlFormatHashtags
public void TweetToHtmlFormatHashtags()
{
var text = "Next #test #like";
var tweet = new Tweet(new TwitterUser(null, null, null, null, null, 0, 0, 0), text, DateTime.MinValue, String.Empty);
Assert.Equal("Next <a href=\"https://www.twitter.com/search/#test\">#test</a> <a href=\"https://www.twitter.com/search/#like\">#like</a>", tweet.TextToHtmlString().ToString());
}
示例11: processTweet
private void processTweet(Tweet tweet, bool force)
{
if (tweet != null)
{
Trace.WriteLine(tweet.text, "Information");
}
}
示例12: AssertSingleTweet
protected void AssertSingleTweet(Tweet tweet)
{
Assert.AreEqual(12345, tweet.ID);
Assert.AreEqual("Tweet 1", tweet.Text);
Assert.IsNotNull(tweet.CreatedAt);
Assert.AreEqual("13/07/2010 17:38:21", tweet.CreatedAt.Value.ToUniversalTime().ToString("dd/MM/yyyy HH:mm:ss"));
Assert.AreEqual("habuma", tweet.User.ScreenName);
Assert.AreEqual(112233, tweet.User.ID);
Assert.AreEqual("http://a3.twimg.com/profile_images/1205746571/me2_300.jpg", tweet.User.ProfileImageUrl);
Assert.AreEqual("habuma", tweet.FromUser); // Deprecated
Assert.AreEqual(112233, tweet.FromUserId); // Deprecated
Assert.AreEqual("http://a3.twimg.com/profile_images/1205746571/me2_300.jpg", tweet.ProfileImageUrl); // Deprecated
Assert.IsNotNull(tweet.InReplyToStatusId);
Assert.AreEqual(123123123123, tweet.InReplyToStatusId.Value);
Assert.IsNotNull(tweet.InReplyToUserId);
Assert.AreEqual(332211, tweet.InReplyToUserId.Value);
Assert.IsNotNull(tweet.ToUserId); // Deprecated
Assert.AreEqual(332211, tweet.ToUserId.Value); // Deprecated
Assert.AreEqual("brbaia", tweet.InReplyToUserScreenName);
Assert.AreEqual("Spring Social Showcase", tweet.Source);
Assert.AreEqual(9, tweet.FavoriteCount);
Assert.AreEqual(12, tweet.RetweetCount);
Assert.IsTrue(tweet.IsRetweetedByUser);
Assert.IsTrue(tweet.IsFavoritedByUser);
}
示例13: GetSearchResults
public TweetCollection GetSearchResults(string searchText, IWebProxy webProxy)
{
TweetCollection tweets = new TweetCollection();
string tweetscanUrl = "http://tweetscan.com/trss.php?s=" + searchText;
HttpWebRequest request = WebRequest.Create(tweetscanUrl) as HttpWebRequest;
// Add configured web proxy
request.Proxy = webProxy;
//try
//{
// Get the Web Response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Load the response data into a XmlDocument
XmlDocument doc = new XmlDocument();
doc.Load(reader);
// Get statuses with XPath
XmlNodeList nodes = doc.SelectNodes("/rss/channel/item");
foreach (XmlNode node in nodes)
{
Tweet tweet = new Tweet();
tweet.Id = double.Parse(node.SelectSingleNode("tweetid").InnerText);
tweet.Text = HttpUtility.HtmlDecode(node.SelectSingleNode("text").InnerText);
string dateString = node.SelectSingleNode("pubdate").InnerText;
if (!string.IsNullOrEmpty(dateString))
{
tweet.DateCreated = DateTime.Parse(dateString);
}
User user = new User();
user.Name = node.SelectSingleNode("username").InnerText;
user.ScreenName = node.SelectSingleNode("screenname").InnerText;
user.ImageUrl = node.SelectSingleNode("image").InnerText;
tweet.User = user;
tweets.Add(tweet);
}
tweets.SaveToDisk();
}
//}
//catch {
////TODO: not sure what kind of errors are thrown by tweetcan
// // eat it.
//}
return tweets;
}
示例14: Create
public void Create(Tweet tweet)
{
using (var context = new TwitterEntities())
{
context.Tweets.Add(tweet);
context.SaveChanges();
}
}
示例15: TweetThis
private static void TweetThis(TwitterClient twitterClient, Tweet tweet, Sender<TweetStatus> sender) {
var response = twitterClient.Tweet(tweet.Message, tweet.Token);
var tweetStatus = new TweetStatus {
CorrelationId = tweet.CorrelationId,
Status = response
};
sender.Send(tweetStatus);
}