本文整理匯總了C#中OpenTween.PostFilterRule.ExecFilter方法的典型用法代碼示例。如果您正苦於以下問題:C# PostFilterRule.ExecFilter方法的具體用法?C# PostFilterRule.ExecFilter怎麽用?C# PostFilterRule.ExecFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenTween.PostFilterRule
的用法示例。
在下文中一共展示了PostFilterRule.ExecFilter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExcludeOnlyTest
public void ExcludeOnlyTest()
{
var filter = new PostFilterRule { ExFilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}
示例2: MatchOnlyTest
public void MatchOnlyTest()
{
var filter = new PostFilterRule { FilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter.ExecFilter(post));
}
示例3: EmptyRuleTest
public void EmptyRuleTest()
{
var filter = new PostFilterRule { };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例4: 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);
}
示例5: 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));
}
示例6: ExFilterSource_ByUrlRegexTest
public void ExFilterSource_ByUrlRegexTest()
{
var filter = new PostFilterRule();
PostClass post;
// ExFilterByUrl = true の場合は Source ではなく SourceHtml がマッチ対象になる
filter.ExFilterByUrl = true;
filter.ExUseRegex = true;
filter.ExFilterSource = "(hoge){2}";
// ExFilterSource は ExUseRegex の値に関わらず部分一致
post = new PostClass { Source = "****", SourceUri = new Uri("http://example.com/hogehoge") };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
post = new PostClass { Source = "****", SourceUri = new Uri("http://example.com/foo") };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を區別する
filter.ExCaseSensitive = true;
post = new PostClass { Source = "****", SourceUri = new Uri("http://example.com/HogeHoge") };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を區別しない
filter.ExCaseSensitive = false;
post = new PostClass { Source = "****", SourceUri = new Uri("http://example.com/HogeHoge") };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}
示例7: ExFilterRt_Test
public void ExFilterRt_Test()
{
var filter = new PostFilterRule();
PostClass post;
filter.ExFilterRt = true;
post = new PostClass { RetweetedBy = "hogehoge", RetweetedId = 123L };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
post = new PostClass { };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例8: FilterSource_RegexTest
public void FilterSource_RegexTest()
{
var filter = new PostFilterRule();
PostClass post;
filter.UseRegex = true;
filter.FilterSource = "(hoge){2}";
post = new PostClass { Source = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter.ExecFilter(post));
post = new PostClass { Source = "foo" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// FilterSource は部分一致 (UseRegex = true の場合)
post = new PostClass { Source = "_hogehoge_" };
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter.ExecFilter(post));
// 大小文字を區別する
filter.CaseSensitive = true;
post = new PostClass { Source = "HogeHoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を區別しない
filter.CaseSensitive = false;
post = new PostClass { Source = "HogeHoge" };
Assert.Equal(MyCommon.HITRESULT.CopyAndMark, filter.ExecFilter(post));
}
示例9: PostMatchOptions_MoveTest
public void PostMatchOptions_MoveTest()
{
var filter = new PostFilterRule { FilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
filter.MoveMatches = true;
filter.MarkMatches = false; // 無視される
Assert.Equal(MyCommon.HITRESULT.Move, filter.ExecFilter(post));
filter.MoveMatches = true;
filter.MarkMatches = true; // 無視される
Assert.Equal(MyCommon.HITRESULT.Move, filter.ExecFilter(post));
}
示例10: ExFilterBody_RegexTest
public void ExFilterBody_RegexTest()
{
var filter = new PostFilterRule();
PostClass post;
filter.ExUseRegex = true;
filter.ExFilterBody = new[] { "a{3}", "b{3}" };
post = new PostClass { TextFromApi = "test" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 片方だけではマッチしない
post = new PostClass { TextFromApi = "aaa" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// ExFilterBody の文字列が全て含まれている
post = new PostClass { TextFromApi = "123aaa456bbb" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
// ScreenName にはマッチしない (ExUseNameField = true の場合)
post = new PostClass { ScreenName = "aaabbb", TextFromApi = "test" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を區別する
filter.ExCaseSensitive = true;
post = new PostClass { TextFromApi = "AaaBbb" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を區別しない
filter.ExCaseSensitive = false;
post = new PostClass { TextFromApi = "AaaBbb" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}
示例11: ShowSearchDialog
/// <summary>
/// 検索ダイアログを表示し、検索を実行します
/// </summary>
private void ShowSearchDialog()
{
if (this.SearchDialog.ShowDialog(this) != DialogResult.OK)
{
this.TopMost = this._cfgCommon.AlwaysTop;
return;
}
this.TopMost = this._cfgCommon.AlwaysTop;
var searchOptions = this.SearchDialog.ResultOptions;
if (searchOptions.Type == SearchWordDialog.SearchType.Timeline)
{
if (searchOptions.NewTab)
{
var tabName = Properties.Resources.SearchResults_TabName;
try
{
tabName = this._statuses.MakeTabName(tabName);
}
catch (TabException ex)
{
MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.AddNewTab(tabName, false, MyCommon.TabUsageType.SearchResults);
this._statuses.AddTab(tabName, MyCommon.TabUsageType.SearchResults, null);
var filter = new PostFilterRule
{
FilterBody = new[] { searchOptions.Query },
UseRegex = searchOptions.UseRegex,
CaseSensitive = searchOptions.CaseSensitive,
};
var targetTab = this._statuses.Tabs[this._curTab.Text];
var posts = targetTab.Posts.Values
.Where(x => filter.ExecFilter(x) == MyCommon.HITRESULT.CopyAndMark)
.Where(x => targetTab.Contains(x.StatusId));
var resultTab = this._statuses.Tabs[tabName];
foreach (var post in posts)
{
resultTab.AddPostToInnerStorage(post);
}
this._statuses.DistributePosts();
this.RefreshTimeline();
var tabPage = this.ListTab.TabPages.Cast<TabPage>()
.First(x => x.Text == tabName);
this.ListTab.SelectedTab = tabPage;
}
else
{
this.DoTabSearch(
searchOptions.Query,
searchOptions.CaseSensitive,
searchOptions.UseRegex,
SEARCHTYPE.DialogSearch);
}
}
else if (searchOptions.Type == SearchWordDialog.SearchType.Public)
{
this.AddNewTabForSearch(searchOptions.Query);
}
}
示例12: SourceHtmlTest
public void SourceHtmlTest(bool useRegex, string pattern, bool exclude)
{
var filter = new PostFilterRule();
PostClass post;
if (!exclude)
{
// FilterByUrl = true の場合は Source ではなく SourceHtml がマッチ対象になる
filter.FilterByUrl = true;
filter.UseRegex = useRegex;
filter.FilterSource = pattern;
}
else
{
// ExFilterByUrl = true の場合は Source ではなく SourceHtml がマッチ対象になる
filter.ExFilterByUrl = true;
filter.ExUseRegex = useRegex;
filter.ExFilterSource = pattern;
}
// FilterSource は UseRegex の値に関わらず部分一致
post = new PostClass { SourceHtml = "<a href='http://example.com/hogehoge'>****</a>" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
post = new PostClass { SourceHtml = "<a href='http://example.com/foo'>****</a>" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
// 大小文字を區別する
if (!exclude)
filter.CaseSensitive = true;
else
filter.ExCaseSensitive = true;
post = new PostClass { SourceHtml = "<a href='http://example.com/HogeHoge'>****</a>" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
// 大小文字を區別しない
if (!exclude)
filter.CaseSensitive = false;
else
filter.ExCaseSensitive = false;
post = new PostClass { SourceHtml = "<a href='http://example.com/HogeHoge'>****</a>" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
}
示例13: ExFilterName_RegexTest
public void ExFilterName_RegexTest()
{
var filter = new PostFilterRule();
PostClass post;
filter.ExUseRegex = true;
filter.ExFilterName = "(hoge){2}";
post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
post = new PostClass { ScreenName = "foo" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// ExFilterName は RetweetedBy にもマッチする
post = new PostClass { ScreenName = "foo", RetweetedBy = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
post = new PostClass { ScreenName = "foo", RetweetedBy = "bar" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// ExFilterName は部分一致 (ExUseRegex = true の場合)
post = new PostClass { ScreenName = "_hogehoge_" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
// 大小文字を區別する
filter.ExCaseSensitive = true;
post = new PostClass { ScreenName = "HogeHoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
// 大小文字を區別しない
filter.ExCaseSensitive = false;
post = new PostClass { ScreenName = "HogeHoge" };
Assert.Equal(MyCommon.HITRESULT.Exclude, filter.ExecFilter(post));
}
示例14: BodyAndNameTest
public void BodyAndNameTest(bool useRegex, string[] pattern, bool exclude)
{
var filter = new PostFilterRule();
PostClass post;
if (!exclude)
{
// UseNameField = false の場合は FilterBody のマッチ対象が Text と ScreenName の両方になる
filter.UseNameField = false;
filter.UseRegex = useRegex;
filter.FilterBody = pattern;
}
else
{
// ExUseNameField = false の場合は ExFilterBody のマッチ対象が Text と ScreenName の両方になる
filter.ExUseNameField = false;
filter.ExUseRegex = useRegex;
filter.ExFilterBody = pattern;
}
post = new PostClass { ScreenName = "hoge", TextFromApi = "test" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
// FilterBody の片方だけではマッチしない
post = new PostClass { ScreenName = "hoge", TextFromApi = "aaa" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
// FilterBody の片方だけではマッチしない
post = new PostClass { ScreenName = "aaa", TextFromApi = "test" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
// TextFromApi に FilterBody の文字列が全て含まれている
post = new PostClass { ScreenName = "hoge", TextFromApi = "123aaa456bbb" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
// TextFromApi と ScreenName に FilterBody の文字列がそれぞれ含まれている
post = new PostClass { ScreenName = "aaa", TextFromApi = "bbb" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
// TextFromApi と RetweetedBy に FilterBody の文字列がそれぞれ含まれている
post = new PostClass { ScreenName = "hoge", TextFromApi = "bbb", RetweetedBy = "aaa" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
// RetweetedBy が null でなくても依然として ScreenName にはマッチする
post = new PostClass { ScreenName = "aaa", TextFromApi = "bbb", RetweetedBy = "hoge" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
if (!useRegex)
{
// ScreenName に対しては完全一致 (UseRegex = false の場合)
post = new PostClass { ScreenName = "_aaa_", TextFromApi = "bbb" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
}
else
{
// ScreenName に対しても部分一致 (UseRegex = true の場合)
post = new PostClass { ScreenName = "_aaa_", TextFromApi = "bbb" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
}
// TextFromApi に対しては UseRegex に関わらず常に部分一致
post = new PostClass { ScreenName = "aaa", TextFromApi = "_bbb_" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
// 大小文字を區別する
if (!exclude)
filter.CaseSensitive = true;
else
filter.ExCaseSensitive = true;
post = new PostClass { ScreenName = "Aaa", TextFromApi = "Bbb" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
post = new PostClass { ScreenName = "hoge", TextFromApi = "Bbb", RetweetedBy = "Aaa" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.None));
// 大小文字を區別しない
if (!exclude)
filter.CaseSensitive = false;
else
filter.ExCaseSensitive = false;
post = new PostClass { ScreenName = "Aaa", TextFromApi = "Bbb" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
post = new PostClass { ScreenName = "hoge", TextFromApi = "Bbb", RetweetedBy = "Aaa" };
Assert.That(filter.ExecFilter(post), Is.EqualTo(exclude ? MyCommon.HITRESULT.Exclude : MyCommon.HITRESULT.CopyAndMark));
}
示例15: PostMatchOptionsTest
public void PostMatchOptionsTest()
{
var filter = new PostFilterRule { FilterName = "hogehoge" };
var post = new PostClass { ScreenName = "hogehoge" };
filter.MoveMatches = false;
filter.MarkMatches = false;
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.Copy));
filter.MoveMatches = false;
filter.MarkMatches = true;
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.CopyAndMark));
filter.MoveMatches = true;
filter.MarkMatches = false; // 無視される
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.Move));
filter.MoveMatches = true;
filter.MarkMatches = true; // 無視される
Assert.That(filter.ExecFilter(post), Is.EqualTo(MyCommon.HITRESULT.Move));
}