本文整理汇总了C#中PostClass类的典型用法代码示例。如果您正苦于以下问题:C# PostClass类的具体用法?C# PostClass怎么用?C# PostClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PostClass类属于命名空间,在下文中一共展示了PostClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetThumbnailInfoAsync
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
{
// ツイートに位置情報が付与されている場合は何もしない
if (post.PostGeo != null)
return null;
var location = await this.FetchCheckinLocation(url, token)
.ConfigureAwait(false);
if (location == null)
{
location = await this.FetchCheckinLocationLegacy(url, token)
.ConfigureAwait(false);
}
if (location != null)
{
var map = MapThumb.GetDefaultInstance();
return await map.GetThumbnailInfoAsync(new PostClass.StatusGeo(location.Longitude, location.Latitude))
.ConfigureAwait(false);
}
return null;
}
示例2: EmptyRuleTest
public void EmptyRuleTest()
{
var filter = new PostFilterRule { };
var post = new PostClass { ScreenName = "hogehoge" };
Assert.Equal(MyCommon.HITRESULT.None, filter.ExecFilter(post));
}
示例3: GetThumbnailInfoAsync
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
{
var match = Tinami.UrlPatternRegex.Match(url);
if (!match.Success)
return null;
var contentId = match.Groups["ContentId"].Value;
try
{
var xdoc = await this.FetchContentInfoApiAsync(contentId, token)
.ConfigureAwait(false);
if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value != "ok")
return null;
var thumbUrlElm = xdoc.XPathSelectElement("/rsp/content/thumbnails/thumbnail_150x150");
if (thumbUrlElm == null)
return null;
var descElm = xdoc.XPathSelectElement("/rsp/content/description");
return new ThumbnailInfo
{
MediaPageUrl = url,
ThumbnailImageUrl = thumbUrlElm.Attribute("url").Value,
TooltipText = descElm == null ? null : descElm.Value,
};
}
catch (HttpRequestException) { }
return null;
}
示例4: GetThumbnailInfoAsync
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
{
var match = Tumblr.UrlPatternRegex.Match(url);
if (!match.Success)
return null;
// 参照: http://www.tumblr.com/docs/en/api/v2#photo-posts
var host = match.Groups["host"].Value;
var postId = match.Groups["postId"].Value;
var param = new Dictionary<string, string>
{
["api_key"] = ApplicationSettings.TumblrConsumerKey,
["id"] = match.Groups["postId"].Value,
};
try
{
var apiUrl = string.Format("https://api.tumblr.com/v2/blog/{0}/posts?", host) + MyCommon.BuildQueryString(param);
using (var response = await this.http.GetAsync(apiUrl, token).ConfigureAwait(false))
{
var jsonBytes = await response.Content.ReadAsByteArrayAsync()
.ConfigureAwait(false);
var thumbs = ParsePhotoPostJson(jsonBytes);
return thumbs.FirstOrDefault();
}
}
catch (HttpRequestException) { } // たまに api.tumblr.com が名前解決できない
return null;
}
示例5: EnqueueRemovePost_SetIsDeletedTest
public void EnqueueRemovePost_SetIsDeletedTest()
{
var tab = new PublicSearchTabModel("search")
{
UnreadManage = true,
};
var post = new PostClass { StatusId = 100L, IsRead = false };
tab.AddPostQueue(post);
tab.AddSubmit();
Assert.Equal(1, tab.AllCount);
Assert.Equal(1, tab.UnreadCount);
tab.EnqueueRemovePost(100L, setIsDeleted: true);
// この時点ではタブからの削除は行われないが、PostClass.IsDeleted は true にセットされる
Assert.Equal(1, tab.AllCount);
Assert.Equal(1, tab.UnreadCount);
Assert.True(post.IsDeleted);
var removedIds = tab.RemoveSubmit();
Assert.Equal(0, tab.AllCount);
Assert.Equal(0, tab.UnreadCount);
Assert.Equal(new[] { 100L }, removedIds.AsEnumerable());
}
示例6: GetThumbnailInfoAsync
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
{
// 前処理で動画用URLが準備されていればそれを使う
var mediaInfo = post.Media.FirstOrDefault(x => x.Url == url);
if (mediaInfo.VideoUrl != null)
{
return new ThumbnailInfo
{
ImageUrl = mediaInfo.VideoUrl,
ThumbnailUrl = url,
IsPlayable = true,
};
}
// amp.twimg.com のメタデータからサムネイル用URLを取得する
var thumbInfo = await base.GetThumbnailInfoAsync(url, post, token)
.ConfigureAwait(false);
if (thumbInfo != null)
{
thumbInfo.IsPlayable = true;
return thumbInfo;
}
return null;
}
示例7: GetThumbnailInfo
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post)
{
var apiUrl = base.ReplaceUrl(url);
if (apiUrl == null) return null;
var xdoc = this.FetchContentInfoApi(apiUrl);
if (xdoc.XPathSelectElement("/rsp").Attribute("stat").Value == "ok")
{
var thumbUrlElm = xdoc.XPathSelectElement("/rsp/content/thumbnails/thumbnail_150x150");
if (thumbUrlElm != null)
{
var descElm = xdoc.XPathSelectElement("/rsp/content/description");
return new ThumbnailInfo()
{
ImageUrl = url,
ThumbnailUrl = thumbUrlElm.Attribute("url").Value,
TooltipText = descElm == null ? null : descElm.Value,
};
}
}
return null;
}
示例8: GetThumbnails
public static List<ThumbnailInfo> GetThumbnails(PostClass post)
{
var thumbnails = new List<ThumbnailInfo>();
if (post.Media != null)
{
foreach (var media in post.Media)
{
var thumbInfo = ThumbnailGenerator.GetThumbnailInfo(media.Value, post);
if (thumbInfo != null)
{
thumbnails.Add(thumbInfo);
}
}
}
if (post.PostGeo != null && !(post.PostGeo.Lat == 0 && post.PostGeo.Lng == 0))
{
var map = MapThumb.GetDefaultInstance();
thumbnails.Add(new ThumbnailInfo()
{
ImageUrl = map.CreateMapLinkUrl(post.PostGeo.Lat, post.PostGeo.Lng),
ThumbnailUrl = map.CreateStaticMapUrl(post.PostGeo.Lat, post.PostGeo.Lng),
TooltipText = null,
});
}
return thumbnails;
}
示例9: CloneTest
public void CloneTest()
{
var post = new PostClass();
var clonePost = post.Clone();
TestUtils.CheckDeepCloning(post, clonePost);
}
示例10: GetThumbnailInfo
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post)
{
var apiUrl = base.ReplaceUrl(url);
if (apiUrl == null) return null;
using (var client = new OTWebClient())
using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(client.DownloadData(apiUrl), XmlDictionaryReaderQuotas.Max))
{
var xElm = XElement.Load(jsonReader);
var thumbUrlElm = xElm.XPathSelectElement("/response/post/thumb_url");
if (thumbUrlElm == null)
{
return null;
}
var textElm = xElm.XPathSelectElement("/response/post/text");
return new ThumbnailInfo()
{
ImageUrl = url,
ThumbnailUrl = thumbUrlElm.Value,
TooltipText = textElm == null ? null : textElm.Value,
};
}
}
示例11: GetThumbnailInfo
public override ThumbnailInfo GetThumbnailInfo(string url, PostClass post)
{
var apiUrl = base.ReplaceUrl(url);
if (apiUrl == null) return null;
var xdoc = XDocument.Load(apiUrl);
var thumbUrlElm = xdoc.XPathSelectElement("/oembed/thumbnail_url");
if (thumbUrlElm != null)
{
var titleElm = xdoc.XPathSelectElement("/oembed/title");
var durationElm = xdoc.XPathSelectElement("/oembed/duration");
var tooltipText = "";
if (titleElm != null && durationElm != null)
{
var duration = int.Parse(durationElm.Value);
var minute = duration / 60;
var second = duration % 60;
tooltipText = string.Format("{0} ({1:00}:{2:00})", titleElm.Value, minute, second);
}
return new ThumbnailInfo()
{
ImageUrl = url,
ThumbnailUrl = thumbUrlElm.Value,
TooltipText = tooltipText,
};
}
return null;
}
示例12: AddPostQueue
public override void AddPostQueue(PostClass post)
{
if (TabInformations.GetInstance().IsMuted(post, isHomeTimeline: false))
return;
this.internalPosts.TryAdd(post.StatusId, post);
base.AddPostQueue(post);
}
示例13: GetThumbnailInfoAsync
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
{
// ツイートに位置情報が付与されている場合は何もしない
if (post.PostGeo.Lat != 0 || post.PostGeo.Lng != 0)
return null;
var match = UrlPatternRegex.Match(url);
if (!match.Success)
return null;
var checkinIdGroup = match.Groups["checkin_id"];
var signatureGroup = match.Groups["signature"];
try
{
// Foursquare のベニュー情報を取得
// 参照: https://developer.foursquare.com/docs/venues/venues
var query = new Dictionary<string, string>
{
{"client_id", ApplicationSettings.FoursquareClientId},
{"client_secret", ApplicationSettings.FoursquareClientSecret},
{"v", "20140419"}, // https://developer.foursquare.com/overview/versioning
};
if (signatureGroup.Success)
query["signature"] = signatureGroup.Value;
var apiUrl = new Uri(ApiBase + "/checkins/" + checkinIdGroup.Value + "?" + MyCommon.BuildQueryString(query));
using (var response = await this.http.GetAsync(apiUrl, token).ConfigureAwait(false))
{
response.EnsureSuccessStatusCode();
var jsonBytes = await response.Content.ReadAsByteArrayAsync()
.ConfigureAwait(false);
var location = ParseIntoLocation(jsonBytes);
if (location == null)
return null;
var map = MapThumb.GetDefaultInstance();
return new ThumbnailInfo
{
ImageUrl = map.CreateMapLinkUrl(location.Latitude, location.Longitude),
ThumbnailUrl = map.CreateStaticMapUrl(location.Latitude, location.Longitude),
TooltipText = null,
};
}
}
catch (HttpRequestException) { }
return null;
}
示例14: AddFiltered
//フィルタに合致したら追加
public MyCommon.HITRESULT AddFiltered(PostClass post, bool immediately = false)
{
if (this.IsInnerStorageTabType)
return MyCommon.HITRESULT.None;
var rslt = MyCommon.HITRESULT.None;
//全フィルタ評価(優先順位あり)
lock (this.lockObjFilters)
{
foreach (var ft in _filters)
{
try
{
switch (ft.ExecFilter(post)) //フィルタクラスでヒット判定
{
case MyCommon.HITRESULT.None:
break;
case MyCommon.HITRESULT.Copy:
if (rslt != MyCommon.HITRESULT.CopyAndMark) rslt = MyCommon.HITRESULT.Copy;
break;
case MyCommon.HITRESULT.CopyAndMark:
rslt = MyCommon.HITRESULT.CopyAndMark;
break;
case MyCommon.HITRESULT.Move:
rslt = MyCommon.HITRESULT.Move;
break;
case MyCommon.HITRESULT.Exclude:
rslt = MyCommon.HITRESULT.Exclude;
goto exit_for;
}
}
catch (NullReferenceException)
{
// ExecFilterでNullRef出る場合あり。暫定対応
MyCommon.TraceOut("ExecFilterでNullRef: " + ft);
rslt = MyCommon.HITRESULT.None;
}
}
exit_for:
;
}
if (this.TabType != MyCommon.TabUsageType.Mute &&
rslt != MyCommon.HITRESULT.None && rslt != MyCommon.HITRESULT.Exclude)
{
if (immediately)
this.AddPostImmediately(post.StatusId, post.IsRead);
else
this.AddPostQueue(post);
}
return rslt; //マーク付けは呼び出し元で行うこと
}
示例15: GetThumbnailInfoAsync
public override Task<ThumbnailInfo> GetThumbnailInfoAsync(PostClass.StatusGeo geo)
{
var thumb = new ThumbnailInfo
{
MediaPageUrl = this.CreateMapLinkUrl(geo.Latitude, geo.Longitude),
ThumbnailImageUrl = this.CreateStaticMapUrl(geo.Latitude, geo.Longitude),
TooltipText = null,
};
return Task.FromResult(thumb);
}