本文整理汇总了C#中OpenTween.PostClass类的典型用法代码示例。如果您正苦于以下问题:C# PostClass类的具体用法?C# PostClass怎么用?C# PostClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PostClass类属于OpenTween命名空间,在下文中一共展示了PostClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmptyRuleTest
public void EmptyRuleTest()
{
var filter = new PostFilterRule { };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例2: CloneTest
public void CloneTest()
{
var post = new PostClass();
var clonePost = post.Clone();
TestUtils.CheckDeepCloning(post, clonePost);
}
示例3: NameTest
public void NameTest()
{
var filter = new FiltersClass();
PostClass post;
filter.NameFilter = "hoge";
post = new PostClass { ScreenName = "hoge", Text = "test" };
Assert.That(filter.IsHit(post), Is.EqualTo(MyCommon.HITRESULT.CopyAndMark));
filter.NameFilter = "hoge";
post = new PostClass { ScreenName = "foo", Text = "test" };
Assert.That(filter.IsHit(post), Is.EqualTo(MyCommon.HITRESULT.None));
// NameFilter は RetweetedBy にもマッチする
filter.NameFilter = "hoge";
post = new PostClass { ScreenName = "foo", Text = "test", RetweetedBy = "hoge" };
Assert.That(filter.IsHit(post), Is.EqualTo(MyCommon.HITRESULT.CopyAndMark));
filter.NameFilter = "hoge";
post = new PostClass { ScreenName = "foo", Text = "test", RetweetedBy = "bar" };
Assert.That(filter.IsHit(post), Is.EqualTo(MyCommon.HITRESULT.None));
// NameFilter は部分一致ではない
filter.NameFilter = "hoge";
post = new PostClass { ScreenName = "hogehoge", Text = "test" };
Assert.That(filter.IsHit(post), Is.EqualTo(MyCommon.HITRESULT.None));
// 大小文字を区別しないオプション
filter.NameFilter = "hoge";
filter.CaseSensitive = false;
post = new PostClass { ScreenName = "Hoge", Text = "test" };
Assert.That(filter.IsHit(post), Is.EqualTo(MyCommon.HITRESULT.CopyAndMark));
}
示例4: ExcludeOnlyTest
public void ExcludeOnlyTest()
{
var filter = new PostFilterRule { ExFilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}
示例5: MatchOnlyTest
public void MatchOnlyTest()
{
var filter = new PostFilterRule { FilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter.ExecFilter(post));
}
示例6: ShowThumbnailAsync
public async Task ShowThumbnailAsync(PostClass post, CancellationToken cancelToken)
{
var loadTasks = new List<Task>();
this.scrollBar.Enabled = false;
if (post.Media.Count == 0 && post.PostGeo.Lat == 0 && post.PostGeo.Lng == 0)
{
this.SetThumbnailCount(0);
if (this.ThumbnailNotFound != null)
this.ThumbnailNotFound(this, EventArgs.Empty);
return;
}
var thumbnails = (await this.GetThumbailInfoAsync(post, cancelToken))
.ToArray();
cancelToken.ThrowIfCancellationRequested();
this.SetThumbnailCount(thumbnails.Length);
if (thumbnails.Length == 0)
{
if (this.ThumbnailNotFound != null)
this.ThumbnailNotFound(this, EventArgs.Empty);
return;
}
for (int i = 0; i < thumbnails.Length; i++)
{
var thumb = thumbnails[i];
var picbox = this.pictureBox[i];
picbox.Tag = thumb;
var loadTask = this.SetThumbnailImageAsync(picbox, thumb, cancelToken);
loadTasks.Add(loadTask);
var tooltipText = thumb.TooltipText;
if (!string.IsNullOrEmpty(tooltipText))
{
this.toolTip.SetToolTip(picbox, tooltipText);
}
cancelToken.ThrowIfCancellationRequested();
}
if (thumbnails.Length > 1)
this.scrollBar.Enabled = true;
if (this.ThumbnailLoading != null)
this.ThumbnailLoading(this, EventArgs.Empty);
await Task.WhenAll(loadTasks).ConfigureAwait(false);
}
示例7: ShowThumbnailAsync
public async Task ShowThumbnailAsync(PostClass post, CancellationToken cancelToken)
{
var loadTasks = new List<Task>();
this.scrollBar.Enabled = false;
this.scrollBar.Visible = false;
if (post.ExpandedUrls.Length == 0 && post.Media.Count == 0 && post.PostGeo == null)
{
this.SetThumbnailCount(0);
return;
}
var thumbnails = (await this.GetThumbailInfoAsync(post, cancelToken))
.ToArray();
cancelToken.ThrowIfCancellationRequested();
this.SetThumbnailCount(thumbnails.Length);
if (thumbnails.Length == 0)
return;
for (int i = 0; i < thumbnails.Length; i++)
{
var thumb = thumbnails[i];
var picbox = this.pictureBox[i];
picbox.Tag = thumb;
picbox.ContextMenuStrip = this.contextMenuStrip;
var loadTask = picbox.SetImageFromTask(() => thumb.LoadThumbnailImageAsync(cancelToken));
loadTasks.Add(loadTask);
var tooltipText = thumb.TooltipText;
if (!string.IsNullOrEmpty(tooltipText))
{
this.toolTip.SetToolTip(picbox, tooltipText);
picbox.AccessibleDescription = tooltipText;
}
cancelToken.ThrowIfCancellationRequested();
}
if (thumbnails.Length > 1)
{
this.scrollBar.Enabled = true;
this.scrollBar.Visible = true;
}
this.ThumbnailLoading?.Invoke(this, EventArgs.Empty);
await Task.WhenAll(loadTasks).ConfigureAwait(false);
}
示例8: CancelAsyncTest
public void CancelAsyncTest()
{
using (var thumbbox = new TweetThumbnail())
{
var post = new PostClass();
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
var task = thumbbox.ShowThumbnailAsync(post);
thumbbox.CancelAsync();
Assert.That(task.IsCanceled, Is.True);
}
}
示例9: CancelAsyncTest
public void CancelAsyncTest()
{
using (var thumbbox = new TweetThumbnail())
{
var post = new PostClass();
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
var task = thumbbox.ShowThumbnailAsync(post);
thumbbox.CancelAsync();
Assert.Throws<AggregateException>(() => task.Wait());
Assert.True(task.IsCanceled);
}
}
示例10: NullTest
public void NullTest()
{
var filter = new PostFilterRule
{
FilterName = null,
FilterSource = null,
ExFilterName = null,
ExFilterSource = null,
};
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
Assert.Throws<ArgumentNullException>(() => filter.FilterBody = null);
Assert.Throws<ArgumentNullException>(() => filter.ExFilterBody = null);
}
示例11: GetThumbnailInfoAsync
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
{
return Task.Run<ThumbnailInfo>(() =>
{
var match = this.regex.Match(url);
if (!match.Success) return null;
return new MockThumbnailInfo
{
ImageUrl = url,
ThumbnailUrl = match.Result(this.replaceUrl),
TooltipText = this.replaceTooltip != null ? match.Result(this.replaceTooltip) : null,
};
});
}
示例12: FormatQuoteTweetHtml_PostClassTest
public void FormatQuoteTweetHtml_PostClassTest()
{
var post = new PostClass
{
StatusId = 12345L,
Nickname = "upsilon",
ScreenName = "kim_upsilon",
Text = "<a href=\"https://twitter.com/twitterapi\">@twitterapi</a> hogehoge",
CreatedAt = new DateTime(2015, 3, 30, 3, 30, 0),
};
// PostClass.Text はリンクを除去するのみでエスケープは行わない
// (TweetFormatter によって既にエスケープされた文字列が格納されているため)
var expected = "<a class=\"quote-tweet-link\" href=\"//opentween/status/12345\">" +
"<blockquote class=\"quote-tweet\">" +
"<p>@twitterapi hogehoge</p> — upsilon (@kim_upsilon) " + DateTime.Parse("2015/03/30 3:30:00") +
"</blockquote></a>";
Assert.Equal(expected, TweetDetailsView.FormatQuoteTweetHtml(post, isReply: false));
}
示例13: FieldNullAwareTest
public void FieldNullAwareTest()
{
var nullPost = new PostClass { Source = null };
// Source が null であっても ArgumentNullException 等を投げない
var filter1 = new PostFilterRule
{
FilterSource = "(hoge){2}",
UseRegex = true,
};
Assert.Equal(MyCommon.HITRESULT.None, filter1.ExecFilter(nullPost));
// null は空文字列と同じ扱いにする
var filter2 = new PostFilterRule
{
FilterSource = "^$",
UseRegex = true,
};
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter2.ExecFilter(nullPost));
}
示例14: GetStatusApi
public string GetStatusApi(bool read,
Int64 id,
ref PostClass post)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return string.Empty;
if (MyCommon._endingFlag) return string.Empty;
HttpStatusCode res = HttpStatusCode.BadRequest;
var content = string.Empty;
try
{
res = twCon.ShowStatuses(id, ref content);
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.OK:
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
break;
case HttpStatusCode.Unauthorized:
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid;
return Properties.Resources.Unauthorized;
case HttpStatusCode.BadRequest:
return "Err:API Limits?";
case HttpStatusCode.Forbidden:
return "Err:protected user's tweet";
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
TwitterDataModel.Status status;
try
{
status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
}
catch(SerializationException ex)
{
MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
return "Json Parse Error(DataContractJsonSerializer)";
}
catch(Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid Json!";
}
var item = CreatePostsFromStatusData(status);
if (item == null) return "Err:Can't create post";
item.IsRead = read;
if (item.IsMe && !read && _readOwnPost) item.IsRead = true;
post = item;
return string.Empty;
}
示例15: RemoveDirectMessage
public string RemoveDirectMessage(long id, PostClass post)
{
if (MyCommon._endingFlag) return string.Empty;
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return string.Empty;
if (MyCommon.TwitterApiInfo.AccessLevel != ApiAccessLevel.None)
{
if (!MyCommon.TwitterApiInfo.IsDirectMessagePermission) return "Auth Err:try to re-authorization.";
}
HttpStatusCode res = HttpStatusCode.BadRequest;
//if (post.IsMe)
// _deletemessages.Add(post)
//}
try
{
res = twCon.DestroyDirectMessage(id);
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.OK:
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
return string.Empty;
case HttpStatusCode.Unauthorized:
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid;
return Properties.Resources.Unauthorized;
case HttpStatusCode.NotFound:
return string.Empty;
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
}