Пример #1
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string file, bool isContext)
        {
            var parsedContent = string.Empty;

            if (!string.IsNullOrEmpty(file))
            {
                if (!isContext)
                {
                    var FSO        = new FileSystemObject(pageInfo.PublishmentSystemId);
                    var parsedFile = FSO.CreateIncludeFile(file, false);

                    if (pageInfo.PublishmentSystemInfo.Additional.IsCreateIncludeToSsi)
                    {
                        var pathDifference = PathUtils.GetPathDifference(PathUtils.MapPath("~/"), PathUtility.MapPath(pageInfo.PublishmentSystemInfo, parsedFile));
                        var virtualUrl     = pathDifference.Replace("\\", "/").Trim('/');
                        parsedContent = $@"<!--#include virtual=""{virtualUrl}""-->";
                    }
                    else
                    {
                        var filePath = PathUtility.MapPath(pageInfo.PublishmentSystemInfo, parsedFile);
                        parsedContent = FileUtils.ReadText(filePath, pageInfo.TemplateInfo.Charset);
                    }
                }
                else
                {
                    var content = StlCacheManager.FileContent.GetIncludeContent(pageInfo.PublishmentSystemInfo, file, pageInfo.TemplateInfo.Charset);
                    content = StlParserUtility.Amp(content);
                    var contentBuilder = new StringBuilder(content);
                    StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo);
                    parsedContent = contentBuilder.ToString();
                }
            }

            return(parsedContent);
        }