当前位置: 首页>>代码示例>>C#>>正文


C# UrlHelper.Route方法代码示例

本文整理汇总了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;
        }
开发者ID:hecubu5,项目名称:sportpicks,代码行数:34,代码来源:ModelToResponseExtensions.cs

示例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;
        }
开发者ID:devkimchi,项目名称:TypeScript-WebApi-Sample,代码行数:14,代码来源:SalutationsController.cs

示例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;
        }
开发者ID:ritterim,项目名称:Supurlative,代码行数:12,代码来源:UrlGenerator.cs

示例4: Route

 public string Route(string routeName, object o, UrlHelper url)
 {
     return url.Route(routeName, o);
 }
开发者ID:SpitfireTS,项目名称:MovieMon,代码行数:4,代码来源:UrlHelperWrapper.cs

示例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;
        }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:11,代码来源:NuGetEntityTypeSerializer.cs


注:本文中的System.Web.Http.Routing.UrlHelper.Route方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。