src/ZKEACMS/Extend/UrlHelperExtend.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Easy.Extend;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.WebUtilities;

namespace ZKEACMS
{
    public static class UrlHelperExtend
    {
        public static string PathContent(this IUrlHelper helper, string path)
        {
            return helper.Content(path.IsNullOrEmpty() ? "~/" : path);
        }

        public static string ImageContent(this IUrlHelper helper, string path)
        {
            if (path.IsNullOrEmpty())
            {
                return helper.PathContent("~/images/not-img-available.jpg");
            }
            return helper.Content(path);
        }

        public static string ValidateCode(this IUrlHelper helper)
        {
            return helper.Action("Code", "Validation", new { module = "Validation" });
        }

        public static string AddQueryToCurrentUrl(this IUrlHelper helper, string name, string value)
        {
            return QueryHelpers.AddQueryString(helper.ActionContext.HttpContext.Request.Path, name, value);
        }
        public static string PostUrl(this IUrlHelper helper, string url, Article.Models.ArticleEntity article)
        {
            return article.Url.IsNullOrWhiteSpace() ? helper.PostUrl(url, article.ID.ToString()) : helper.CustomUrl(url, article.Url);
        }
        public static string PostUrl(this IUrlHelper helper, string url, Product.Models.ProductEntity product)
        {
            return product.Url.IsNullOrWhiteSpace() ? helper.PostUrl(url, product.ID.ToString()) : helper.CustomUrl(url, product.Url);
        }
        public static string PostUrl(this IUrlHelper helper, string url, int id)
        {
            return PostUrl(helper, url, id.ToString());
        }
        public static string PostUrl(this IUrlHelper helper, string url, string id)
        {
            if (url.IsNullOrWhiteSpace())
            {
                url = "/";
            }
            return helper.Content($"{url}{(url.EndsWith("/") ? "" : "/")}{StringKeys.PathFormat(StringKeys.RouteValue_Post)}{id}.html");
        }
        public static string CustomUrl(this IUrlHelper helper, string url, string ending, bool staticUrl = true)
        {
            if (url.IsNullOrWhiteSpace())
            {
后面还有 93 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。