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


C# this.Action方法代码示例

本文整理汇总了C#中this.Action方法的典型用法代码示例。如果您正苦于以下问题:C# this.Action方法的具体用法?C# this.Action怎么用?C# this.Action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.Action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImageThumb

        /// <summary>
        /// Returns an URL to entry thumbnail image.
        /// Currently only used for album and artist main images.
        /// 
        /// Gets the URL to the static images folder on disk if possible,
        /// otherwise gets the image from the DB.
        /// </summary>
        /// <param name="urlHelper">URL helper. Cannot be null.</param>
        /// <param name="imageInfo">Image information. Cannot be null.</param>
        /// <param name="size">Requested image size.</param>
        /// <param name="fullUrl">
        /// Whether the URL should always include the hostname and application path root.
        /// If this is false (default), the URL maybe either full (such as http://vocadb.net/Album/CoverPicture/123)
        /// or relative (such as /Album/CoverPicture/123).
        /// Usually this should be set to true if the image is to be referred from another domain.
        /// </param>
        /// <returns>URL to the image thumbnail.</returns>
        public static string ImageThumb(this UrlHelper urlHelper, IEntryImageInformation imageInfo, ImageSize size, bool fullUrl = false)
        {
            if (imageInfo == null)
                return null;

            var shouldExist = ShouldExist(imageInfo);
            string dynamicUrl = null;

            // Use MVC dynamic actions when requesting original or an image that doesn't exist on disk.
            if (imageInfo.EntryType == EntryType.Album) {

                if (size == ImageSize.Original)
                    dynamicUrl = urlHelper.Action("CoverPicture", "Album", new { id = imageInfo.Id, v = imageInfo.Version });
                else if (shouldExist && !imagePersister.HasImage(imageInfo, size))
                    dynamicUrl = urlHelper.Action("CoverPictureThumb", "Album", new { id = imageInfo.Id, v = imageInfo.Version });

            } else if (imageInfo.EntryType == EntryType.Artist) {

                if (size == ImageSize.Original)
                    dynamicUrl = urlHelper.Action("Picture", "Artist", new { id = imageInfo.Id, v = imageInfo.Version });
                else if (shouldExist && !imagePersister.HasImage(imageInfo, size))
                    dynamicUrl = urlHelper.Action("PictureThumb", "Artist", new { id = imageInfo.Id, v = imageInfo.Version });

            }

            if (dynamicUrl != null) {
                return (fullUrl ? AppConfig.HostAddress + dynamicUrl : dynamicUrl);
            }

            if (!shouldExist)
                return GetUnknownImageUrl(urlHelper, imageInfo);

            return imagePersister.GetUrlAbsolute(imageInfo, size, WebHelper.IsSSL(HttpContext.Current.Request));
        }
开发者ID:realzhaorong,项目名称:vocadb,代码行数:51,代码来源:UrlHelperExtenderForImages.cs

示例2: Artwork

 public static string Artwork(this UrlHelper helper, WebMediaType mediaType, string id, string protocol = null, string hostName = null)
 {
     switch (mediaType)
     {
         case WebMediaType.Movie:
             return helper.Action("Cover", "MovieLibrary", new RouteValueDictionary(new { movie = id }), protocol, hostName);
         case WebMediaType.MusicAlbum:
             return helper.Action("AlbumImage", "MusicLibrary", new RouteValueDictionary(new { album = id }), protocol, hostName);
         case WebMediaType.MusicArtist:
             return helper.Action("ArtistImage", "MusicLibrary", new RouteValueDictionary(new { artist = id }), protocol, hostName);
         case WebMediaType.MusicTrack:
             return helper.Action("TrackImage", "MusicLibrary", new RouteValueDictionary(new { track = id }), protocol, hostName);
         case WebMediaType.Radio:
         case WebMediaType.TV:
             return helper.Action("ChannelLogo", "Television", new RouteValueDictionary(new { channelId = id }), protocol, hostName);
         case WebMediaType.Recording:
             // TODO: Make width configurable with a parameter (object attributes or something like it)
             return helper.Action("PreviewImage", "Recording", new RouteValueDictionary(new { id = id, width = 640 }), protocol, hostName);
         case WebMediaType.TVEpisode:
             return helper.Action("EpisodeImage", "TVShowsLibrary", new RouteValueDictionary(new { episode = id }), protocol, hostName);
         case WebMediaType.TVSeason:
             return helper.Action("SeasonImage", "TVShowsLibrary", new RouteValueDictionary(new { season = id }), protocol, hostName);
         case WebMediaType.TVShow:
             return helper.Action("SeriesPoster", "TVShowsLibrary", new RouteValueDictionary(new { season = id }), protocol, hostName);
         default:
             return String.Empty;
     }
 }
开发者ID:jpykie,项目名称:MPExtended,代码行数:28,代码来源:UrlHelperExtensionMethods.cs

示例3: EditorFor

        /// <summary>
        /// Renders editor for the specified page content item.
        /// </summary>
        public static MvcHtmlString EditorFor(this HtmlHelper html, PageContentModel content)
        {
            var settings = PageContentSerializer.Deserialize<PageContentDescription>(content.Settings);

            // if action or controller is not specified we will show default content editor
            if (string.IsNullOrWhiteSpace(settings.Edit.Action) || string.IsNullOrWhiteSpace(settings.Edit.Controller))
            {
                return html.Action("DefaultContentEditor", "Page", new {settings});
            }

            return html.Action(settings.Edit.Action, settings.Edit.Controller, new {content = content.Content, pageContentModel = content});
        }
开发者ID:knstntn,项目名称:NedoCms,代码行数:15,代码来源:PageExtensions.cs

示例4: AbsoluteAction

        public static string AbsoluteAction(this UrlHelper helper, string action,
            string controller, object routeValues = null)
        {
            var requestUri = helper.RequestContext.HttpContext.Request.Url;

              string actionUrl = (routeValues == null) ?
            helper.Action(action, controller) :
            helper.Action(action, controller, routeValues);

              return string.Format("{0}://{1}{2}",
            requestUri.Scheme,
            requestUri.Authority,
            actionUrl);
        }
开发者ID:chakrit,项目名称:mvc-utils,代码行数:14,代码来源:UrlHelperExtensions.cs

示例5: CreateSortLink

    public static string CreateSortLink(this UrlHelper url, string action, string columnName)
    {
        string result = "";

            //read the current request to see if there's a sort value
            string currentDirection = url.RequestContext.HttpContext.Request.QueryString["dir"];
            string currentSort = url.RequestContext.HttpContext.Request.QueryString["s"];

            if (string.IsNullOrEmpty(currentDirection) &! string.IsNullOrEmpty(currentSort)) {
                result = url.Action(action, new { s = columnName, dir = "desc" });
            } else {
                result = url.Action(action, new { s = columnName});
            }
            return result;
    }
开发者ID:minhajuddin,项目名称:playground,代码行数:15,代码来源:TableHelpers.cs

示例6: AbsoluteAction

 public static string AbsoluteAction(this UrlHelper url, string action, string controller, object routeValues = null)
 {
     var request = url.RequestContext.HttpContext.Request;
     var actionUrl = url.Action(action, controller, routeValues, request.Url.Scheme);
     var relativeUri = url.ToRelativeUri(actionUrl);
     return url.ToPublicUrl(relativeUri);
 }
开发者ID:fr4gles,项目名称:Building-Blocks,代码行数:7,代码来源:UrlExtensions.cs

示例7: NewsLink

 public static string NewsLink(this UrlHelper helper, News news)
 {
     if(string.IsNullOrEmpty(news.UrlKey)){
     return helper.Action("ViewNewsById", "Content", new {id=news.NewsID, area="Content"});
     }
     return helper.RouteUrl("News-View-Route", new { category = news.Category.StaticName, area = "Content" , news=news.UrlKey});
 }
开发者ID:samuraitruong,项目名称:gmr,代码行数:7,代码来源:UrlHelperExtensions.cs

示例8: RenderDocTypeGridEditorItem

        public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
            IPublishedContent content,
            string viewPath = "",
            string actionName = "",
            object model = null)
        {
            if (content == null)
                return new HtmlString(string.Empty);

            var controllerName = content.DocumentTypeAlias + "Surface";

            if (!string.IsNullOrWhiteSpace(viewPath))
                viewPath = viewPath.TrimEnd('/') + "/";

            if (string.IsNullOrWhiteSpace(actionName))
                actionName = content.DocumentTypeAlias;

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            if (umbracoHelper.SurfaceControllerExists(controllerName, actionName, true))
            {
                return helper.Action(actionName, controllerName, new
                {
                    dtgeModel = model ?? content,
                    dtgeViewPath = viewPath
                });
            }

            if (!string.IsNullOrWhiteSpace(viewPath))
                return helper.Partial(viewPath + content.DocumentTypeAlias + ".cshtml", content);

            return helper.Partial(content.DocumentTypeAlias, content);
        }
开发者ID:nvisage-gf,项目名称:umbraco-doc-type-grid-editor,代码行数:32,代码来源:HtmlHelperExtensions.cs

示例9: ActionUrl

        public static string ActionUrl(this UrlHelper helper, string area, string controller, string action, object routeValues = null)
        {
            var rVals = routeValues == null ? new RouteValueDictionary() : new RouteValueDictionary(routeValues);
            if (area != null) rVals["area"] = area;

            return helper.Action(action, controller, rVals);
        }
开发者ID:AlexeyRaga,项目名称:Ziggurat,代码行数:7,代码来源:LinkHelper.cs

示例10: AbsoluteAction

        /// <summary>
        /// Generates a fully qualified URL to an action method by using
        /// the specified action name, controller name and route values.
        /// </summary>
        /// <param name="url">The URL helper.</param>
        /// <param name="actionName">The name of the action method.</param>
        /// <param name="controllerName">The name of the controller.</param>
        /// <param name="routeValues">The route values.</param>
        /// <returns>The absolute URL.</returns>
        public static string AbsoluteAction(this UrlHelper url,
            string actionName, string controllerName, object routeValues = null)
        {
            string scheme = url.RequestContext.HttpContext.Request.Url.Scheme;

            return url.Action(actionName, controllerName, routeValues, scheme);
        }
开发者ID:yasenm,项目名称:NewsSystem,代码行数:16,代码来源:UrlHelpers.cs

示例11: DisplayWidgets

 public static MvcHtmlString DisplayWidgets(this HtmlHelper htmlHelper, string widgetLocation)
 {
     return htmlHelper.Action("WidgetDisplay", "Widget", new RouteValueDictionary()
     {
         {"widgetLocation", widgetLocation}
     });
 }
开发者ID:Console-Byte,项目名称:mobsocial,代码行数:7,代码来源:HtmlHelperExtensions.cs

示例12: HotelEdit

 public static string HotelEdit(this UrlHelper urlHelper, HotelPart hotelPart)
 {
     return urlHelper.Action(
         "Edit",
         "HotelAdmin",
         new { destinationId = hotelPart.DestinationPart.Id, hotelId = hotelPart.Id, area = "Summit.Core" });
 }
开发者ID:ThinkPublishing,项目名称:Summit.Core,代码行数:7,代码来源:UrlHelperExtensions.cs

示例13: GenerateLink

        public static string GenerateLink(
            this IUrlHelper urlHelper,
            LinkGenerationTestContext linkGenerationTestContext,
            ControllerTestContext controllerTestContext)
        {
            string uri = null;
            if (!string.IsNullOrWhiteSpace(linkGenerationTestContext.Location))
            {
                uri = linkGenerationTestContext.Location;
            }
            else if (!string.IsNullOrWhiteSpace(linkGenerationTestContext.RouteName))
            {
                uri = urlHelper.RouteUrl(
                    linkGenerationTestContext.RouteName,
                    linkGenerationTestContext.RouteValues);
            }
            else
            {
                linkGenerationTestContext.Action = linkGenerationTestContext.Action
                    ?? controllerTestContext.RouteData.Values["action"] as string
                    ?? controllerTestContext.ActionName;

                linkGenerationTestContext.Controller = linkGenerationTestContext.Controller
                    ?? controllerTestContext.RouteData.Values["controller"] as string
                    ?? controllerTestContext.ControllerContext.ActionDescriptor.ControllerName;

                uri = urlHelper.Action(
                    linkGenerationTestContext.Action,
                    linkGenerationTestContext.Controller,
                    linkGenerationTestContext.RouteValues);
            }

            return uri;
        }
开发者ID:Cream2015,项目名称:MyTested.AspNetCore.Mvc,代码行数:34,代码来源:UrlHelperExtensions.cs

示例14: CommentsCount

        public static MvcHtmlString CommentsCount(this HtmlHelper helper, string navigateUrl, string threadKey, string threadType, bool? allowComments = null)
        {
            if (SystemManager.GetModule("Comments") == null || string.IsNullOrEmpty(threadKey))
                return MvcHtmlString.Empty;

            if (string.IsNullOrEmpty(navigateUrl))
            {
                navigateUrl = "#comments-" + threadKey;
            }

            var controllerName = threadKey.EndsWith(ReviewsSuffix, StringComparison.Ordinal) ? CommentsHelpers.ReviewsControllerName : CommentsHelpers.CommentsControllerName;

            MvcHtmlString result;
            try
            {
                result = helper.Action(CommentsHelpers.CountActionName, controllerName, new { NavigateUrl = navigateUrl, ThreadKey = threadKey, ThreadType = threadType, AllowComments = allowComments });
            }
            catch (HttpException)
            {
                result = MvcHtmlString.Empty;
            }
            catch (NullReferenceException)
            {
                //// Telerik.Sitefinity.Mvc.SitefinityMvcRoute GetOrderedParameters() on line 116 controllerType.GetMethods() throws null reference exception (controllerType is null).
                result = MvcHtmlString.Empty;
            }

            return result;
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:29,代码来源:CommentsHelpers.cs

示例15: AbsoluteAction

        public static string AbsoluteAction(this UrlHelper urlHelper, String actionName, String controllerName = null, Object routeValues = null)
        {
            var url = urlHelper.RequestContext.HttpContext.Request.Url;
            var scheme = (url != null) ? url.Scheme : "http";

            return urlHelper.Action(actionName, controllerName, routeValues, scheme);
        }
开发者ID:IvAlex1986,项目名称:QuickBooks.Net,代码行数:7,代码来源:UrlHelperExtension.cs


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