本文整理汇总了C#中IRenderContext.ParsePath方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.ParsePath方法的具体用法?C# IRenderContext.ParsePath怎么用?C# IRenderContext.ParsePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.ParsePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CurrentRequestSessions
/// <summary>
/// Generates some script tags that you insert into your view.
/// You should probably call this from a helper depending on your view engine.
/// </summary>
/// <param name="renderContext">The current Nancy Render Context</param>
/// <returns></returns>
public static string CurrentRequestSessions(IRenderContext renderContext)
{
var rootUrl = renderContext.ParsePath("~" + ModulePath) + "/";
var sessionIdList = GetCurrentSessionIdList(renderContext.Context);
return CurrentRequestSessions(rootUrl, sessionIdList);
}
示例2: GetStreamLinksHtml
public static IHtmlString GetStreamLinksHtml(int malAnimeId, GetRecsViewModel model, IRenderContext renderContext)
{
List<string> streamLinks = new List<string>();
if (model.StreamsByAnime.ContainsKey(malAnimeId))
{
foreach (streaming_service_anime_map serviceMap in model.StreamsByAnime[malAnimeId]
.OrderBy(map => map.streaming_service_id))
{
StreamingService service = (StreamingService)serviceMap.streaming_service_id;
string imagePath;
string altText;
string titleText;
switch (service)
{
case StreamingService.Crunchyroll:
imagePath = renderContext.ParsePath("~/Content/crunchyroll_icon.png");
altText = "Crunchyroll";
titleText = "Watch on Crunchyroll";
break;
case StreamingService.Funimation:
imagePath = renderContext.ParsePath("~/Content/funimation_icon.png");
altText = "Funimation";
titleText = "Watch on Funimation";
break;
case StreamingService.Viz:
imagePath = renderContext.ParsePath("~/Content/viz_icon.png");
altText = "Viz";
titleText = "Watch on Viz";
break;
case StreamingService.Hulu:
imagePath = renderContext.ParsePath("~/Content/hulu_icon.png");
altText = "Hulu";
titleText = "Watch on Hulu";
break;
default:
continue;
}
string imgHtml = string.Format(@"<img src={0} title={1} alt={2} />",
AttributeString(imagePath), AttributeString(titleText), AttributeString(altText));
string linkHtml = string.Format(@"<a href={0}>{1}</a>", AttributeString(serviceMap.streaming_url), imgHtml);
streamLinks.Add(linkHtml);
}
}
string linksHtml = string.Join(" ", streamLinks);
return new NonEncodedHtmlString(linksHtml);
}