src/ZKEACMS.Redirection/Models/UrlRedirect.cs

(开头部分) 2KB

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

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

using Easy.LINQ;
using Easy.MetaData;
using Easy.Models;
using Easy.RepositoryPattern;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using ZKEACMS.Extend;
using System.Text.RegularExpressions;

namespace ZKEACMS.Redirection.Models
{
    [DataTable("CMS_Redirection")]
    public class UrlRedirect : EditorEntity
    {
        [Key]
        public int ID { get; set; }
        public string InComingUrl { get; set; }
        public string DestinationURL { get; set; }
        public bool IsPermanent { get; set; }
        public bool? IsPattern { get; set; }
        private Regex _regex;
        public bool IsMatch(string path)
        {
            if (IsPattern ?? false)
            {
                if (_regex == null)
                {
                    ParsePattern();
                }
                return _regex.IsMatch(path);
            }

            return path.Equals(InComingUrl, StringComparison.OrdinalIgnoreCase);
        }
        public void ParsePattern()
        {
            if (!string.IsNullOrEmpty(InComingUrl))
            {
                _regex = new Regex(InComingUrl, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            }
        }
        public string GetDestinationURL(string inComingUrl)
        {
            if (IsPattern ?? false && IsPatternDestination())
            {
                return _regex.Replace(inComingUrl, DestinationURL);
            }
            return DestinationURL;
        }
        private bool IsPatternDestination()
        {
            for (int i = 0; i < DestinationURL.Length; i++)
后面还有 19 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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