本文整理汇总了C#中System.Web.Http.Routing.UrlHelper.Route方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.Route方法的具体用法?C# UrlHelper.Route怎么用?C# UrlHelper.Route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.Routing.UrlHelper
的用法示例。
在下文中一共展示了UrlHelper.Route方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToResponse
public static GameResponse ToResponse(this Game game, UrlHelper urlHelper = null)
{
var response = new GameResponse
{
AwayTeam = game.AwayTeam,
AwayTeamScore = game.AwayTeamScore,
GameTime = game.GameTime,
HomeTeam = game.HomeTeam,
HomeTeamScore = game.HomeTeamScore,
Id = game.Id,
IsGameOver = game.IsGameOver,
Season = game.Season,
SeasonType = game.SeasonType,
Week = game.Week,
WinningTeamId = game.WinningTeamId
};
if (game.Options != null)
{
response.Options = game.Options.ToResponse(urlHelper);
if (urlHelper != null)
{
var canModifyPicks = game.Options.Any(option => option.Pick != null && !option.IsPastCutOff);
if (canModifyPicks)
{
response.Actions.Add("deletePicks", urlHelper.Route("DeletePicksForGame", new { id = game.Id }));
}
}
}
return response;
}
示例2: FindLinks
/// <summary>
/// Gets the list of links for salutations for entry.
/// </summary>
/// <param name="urlHelper">Url helper</param>
/// <returns>Returns the list of <see cref="Link" /> objects.</returns>
public static IEnumerable<Link> FindLinks(UrlHelper urlHelper)
{
var links = new List<Link>()
{
new Link() { Rel = "salutations", Href = urlHelper.Route(SalutationsRouteName, new { }) },
};
return links;
}
示例3: Generate
public string Generate(string routeName, object request)
{
var urlHelper = new UrlHelper(_requestMessage);
var values = request.TraverseForKeys(options: Options);
var link = Options.UriKind == UriKind.Relative
? urlHelper.Route(routeName, values)
: urlHelper.Link(routeName, values);
return link;
}
示例4: Route
public string Route(string routeName, object o, UrlHelper url)
{
return url.Route(routeName, o);
}
示例5: BuildLinkForStreamProperty
private static Uri BuildLinkForStreamProperty(string routePrefix, string id, string version, HttpRequestMessage request)
{
var url = new UrlHelper(request);
var result = url.Route(routePrefix + RouteName.DownloadPackage, new { id, version });
var builder = new UriBuilder(request.RequestUri);
builder.Path = version == null ? EnsureTrailingSlash(result) : result;
builder.Query = string.Empty;
return builder.Uri;
}