Discuz.Forum/NVelocity.cs

(开头部分) 3KB

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

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Commons.Collections;
using NVelocity;
using NVelocity.App;
using NVelocity.Context;
using System.IO;
using NVelocity.Runtime;
using System.Text;
using Discuz.Common;
using Discuz.Config;


namespace Discuz.Forum
{

    public class NVelocity
    {
        public static VelocityEngine engine;
        public static ExtendedProperties props;
        public static string filePath = "";
        public static Template template;
        static NVelocity()
        {
            filePath = Utils.GetMapPath(BaseConfigs.GetForumPath);
            engine = new VelocityEngine();
            props = new ExtendedProperties();
            props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
            props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
            props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, filePath);
            engine.Init(props);
        }

        public static string GetTemplateData(string name)
        {
            template = engine.GetTemplate(name);
            return template.Data.ToString();
        }

        public static string TemplateMerge(string name, Hashtable table)
        {
            template = engine.GetTemplate(filePath+name);
            VelocityContext content = new VelocityContext();
            foreach (DictionaryEntry entry in table)
            {
                content.Put(entry.Key.ToString(), entry.Value);
            }
            StringWriter writer = new StringWriter();
            template.Merge(content, writer);
            return writer.GetStringBuilder().ToString();
        }
        public static string StringMerge(string templateContext, Hashtable table)
        {
            var engine = new VelocityEngine();
            engine.Init();
后面还有 33 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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