Example #1
0
        /// <summary>解析模板虚拟路径</summary>
        /// <param name="context">上下文环境</param>
        /// <param name="templateValue">模板信息</param>
        /// <returns></returns>
        public string ParseTemplateVirtualPath(VelocityContext context, string virtualPath)
        {
            string templateValue = null;

            if (VelocityConfigurationView.Instance.TemplateCacheMode == "ON")
            {
                lock (lockDictionaryObject)
                {
                    if (dictionary.ContainsKey(virtualPath))
                    {
                        templateValue = dictionary[virtualPath];
                    }
                    else
                    {
                        templateValue = File.ReadAllText(VirtualPathHelper.GetPhysicalPath(virtualPath));

                        dictionary.Add(virtualPath, templateValue);
                    }
                }
            }
            else
            {
                templateValue = File.ReadAllText(VirtualPathHelper.GetPhysicalPath(virtualPath));
            }

            return(Evaluate(context, templateValue));
        }
        /// <summary>保存配置信息</summary>
        public void Save()
        {
            string path = null;

            if (HttpContext.Current == null)
            {
                path = string.Format("{0}.config", Process.GetCurrentProcess().MainModule.FileName);
            }
            else
            {
                path = VirtualPathHelper.GetPhysicalPath("~/web.config");
            }

            this.Serialize(path, KernelConfiguration.SectionName, this);
        }
 protected override Stream ObtainStream()
 {
     return(FileHelper.ToStream(VirtualPathHelper.GetPhysicalPath(name)));
 }