亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

one.asp多項(xiàng)目、函數(shù)庫(kù)、類庫(kù) 統(tǒng)一為一個(gè)版本的方法

瀏覽:114日期:2022-06-04 17:56:51

前幾天 寫的博客 多項(xiàng)目 函數(shù)庫(kù)、類庫(kù) 統(tǒng)一為一個(gè)版本的方法中提到 使用 one.php 將整個(gè)項(xiàng)目打包成 一個(gè) php 文件,有網(wǎng)友 讓我 整個(gè)asp版本的,今天下午抽空寫了個(gè) one.asp,使用方式基本一致,這次 增加了路徑計(jì)算的功能,可以引用不同路徑。

舉個(gè)簡(jiǎn)單的應(yīng)用場(chǎng)景,開發(fā)一個(gè)小的API系統(tǒng),支持 XML、JSON輸出。區(qū)別是 基礎(chǔ)版(dev/dev.asp)只支持 Access,VIP版本(dev/vip.asp)支持 Access + SQL Server。這樣VIP版本就需要在現(xiàn)在的基礎(chǔ)上 增加 sqlserver的支持,增加額外的 配置項(xiàng)。開發(fā)過程只需要 按正常開發(fā)即可。

開發(fā)完畢后,通過 one.asp 打包成 index.asp 和 vip.asp 兩個(gè)版本,整套程序都是一個(gè)獨(dú)立的文件。

下圖演示了 解析過程:

完整的測(cè)試代碼 可以 訪問:oneasp.rar 下載

核心代碼 如下:

" ====================================================
" 類名:One
" 作者:mqycn
" 博客:http://www.miaoqiyuan.cn
" 源碼:http://www.miaoqiyuan.cn/p/one-php
" 說明:多項(xiàng)目 函數(shù)庫(kù)、類庫(kù) 統(tǒng)一為一個(gè)版本的方法
" ====================================================
Class OneAsp
  Private FSO
  Private Root
   
  Private Sub Class_Initialize()
    Set FSO = Server.CreateObject("Scripting.FileSystemObject")
  End Sub
   
  Private Sub Class_Terminate()
    Set FSO = Nothing
  End Sub
   
  Public Function Run(ByVal sourceFile, ByVal saveFile)
    Run = "<hr><b>Input:</b>" & sourceFile & "<br><b>Result:</b>" & Save(saveFile, Include(sourceFile))
  End Function
   
   
  Public Function Include(ByVal path)
    Dim tmpPath, tmpItem, arrPath, index
    tmpPath = ""
    arrPath = Split(path, "/")
    For index = 0 To UBound(arrPath) - 1
      tmpItem = arrPath(index)
      tmpPath = tmpPath & tmpItem & "/"
    Next
    Include = Parse(tmpPath, arrPath(UBound(arrPath)))
  End Function
   
  Private Function Parse(ByVal root, ByVal fileName)
    Call SetRoot(root)
    Dim html
    html = OpenRead(fileName)
     
    Dim preg, pregResult
    Set preg = New Regexp
    preg.pattern = "<!--#include file=""([^""]*)""-->"
    preg.global = True
    preg.ignorecase = True
     
    Dim htmlInclude
    Set pregResult = preg.execute(html)
    For Each htmlInclude In pregResult
      html = Replace(html, htmlInclude, Include(root & htmlInclude.submatches(0)))
    Next
     
    Parse = "<% "" & root & fileName & " Start %" & ">" & vbCrLf & html & vbCrLf & "<%  "" & root & fileName & " End %" & ">" & vbCrLf
  End Function
   
  Private Function SetRoot(ByVal rootPath)
    If Right(rootPath, 1) <> "/" Then rootPath = rootPath & "/"
    Root = rootPath
  End Function
   
  Private Function RealPath(ByVal path)
    RealPath = Server.Mappath(Root & path)
  End Function
   
  Private Function OpenRead(ByVal path)
    Dim txtFile
    Set txtFile = FSO.OpenTextFile(RealPath(path))
    OpenRead = txtFile.ReadAll()
    txtFile.close
    On Error GoTo 0
  End Function
   
  Public Function Save(ByVal path, ByVal body)
    Dim txtFile
    Set txtFile = FSO.CreateTextFile(Server.Mappath(path))
    txtFile.write body
    txtFile.close
    Set txtFile = Nothing
    Save = path
  End Function
   
End Class

使用也非常簡(jiǎn)單,使用 Call new OneAsp.run(開發(fā)版, 打包版),可以 dev.asp 中的所有包含的代碼 打包到 index.asp,如果只想獲取解析的內(nèi)容,可以使用 Response.Write Server.Htmlencode(Call new OneAsp.include(開發(fā)版))

標(biāo)簽: ASP
相關(guān)文章:
主站蜘蛛池模板: 国产精品免费精品自在线观看 | 一级香蕉视频在线观看 | 久久99综合国产精品亚洲首页 | 老司机成人精品视频lsj | 伊人高清视频 | 欧美在线观看成人高清视频 | 黄色在线观看视频免费 | 国产激情一区二区三区在线观看 | 青青草一区国产97 | 九九九久久久 | 国产成人啪精品 | 日韩三级小视频 | 明星换脸高清一区二区 | 做爰成人五级在线视频 | 激情综合色五月丁香六月亚洲 | 成人a视频在线观看 | 在线免费观看一级毛片 | 青青热久免费精品视频精品 | 青草视频久久 | 日本黄色片一级片 | 97免费在线视频 | 伊人情涩网 | 日本一级特黄在线播放 | 欧美不卡一区二区三区 | 性生活网站 | 在线播放国产区 | 亚洲精品国产福利在线观看 | 激情影院成人区免费观看视频 | 免费观看欧美一区二区三区 | 欧美日韩国产亚洲人成 | 午夜剧场福利社 | 国内在线精品 | 欧美俄罗斯一级毛片激情 | 国内成人啪啪网站 | 黄色一级片美国 | 国产欧美精品国产国产专区 | 国产小视频在线观看免费 | www.日韩三级 | 国产精品久久国产三级国电话系列 | 57pao一国产成永久免费 | 好黄好猛好爽好痛的视频 |