src/SSCMS.Core/StlParser/StlElement/StlRequest.cs

(开头部分) 4KB

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

using System.Collections.Specialized;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using SSCMS.Core.StlParser.Attributes;
using SSCMS.Services;
using SSCMS.Utils;

namespace SSCMS.Core.StlParser.StlElement
{
    [StlElement(Title = "URL地址请求", Description = "通过 stl:request 实体在模板中显示地址栏请求参数")]
    public static class StlRequest
    {
        public const string ElementName = "stl:request";

        [StlAttribute(Title = "地址参数名称")]
        private const string Type = nameof(Type);

        [StlAttribute(Title = "指定需要显示地址参数值的HTML元素Id")]
        private const string ElementId = nameof(ElementId);

        [StlAttribute(Title = "回调函数名称")]
        private const string Callback = nameof(Callback);

        public static async Task<object> ParseAsync(IParseManager parseManager)
        {
            var type = string.Empty;
            var elementId = string.Empty;
            var callback = string.Empty;
            
            var attributes = new NameValueCollection();

            foreach (var name in parseManager.ContextInfo.Attributes.AllKeys)
            {
                var value = parseManager.ContextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, Type))
                {
                    type = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, ElementId))
                {
                    elementId = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, Callback))
                {
                    callback = value;
                }
                else
                {
                    attributes[name] = value;
                }
            }

            return await ParseAsync(parseManager, type, elementId, callback, attributes);
        }

        private static async Task<string> ParseAsync(IParseManager parseManager, string type, string elementId, string callback, NameValueCollection attributes)
        {
            var pageInfo = parseManager.PageInfo;
后面还有 68 行代码,解锁后查看完整代码

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

AI 解读

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

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