午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

one.asp多項目、函數庫、類庫 統一為一個版本的方法

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

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

舉個簡單的應用場景,開發一個小的API系統,支持 XML、JSON輸出。區別是 基礎版(dev/dev.asp)只支持 Access,VIP版本(dev/vip.asp)支持 Access + SQL Server。這樣VIP版本就需要在現在的基礎上 增加 sqlserver的支持,增加額外的 配置項。開發過程只需要 按正常開發即可。

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

下圖演示了 解析過程:

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

核心代碼 如下:

" ====================================================
" 類名:One
" 作者:mqycn
" 博客:http://www.miaoqiyuan.cn
" 源碼:http://www.miaoqiyuan.cn/p/one-php
" 說明:多項目 函數庫、類庫 統一為一個版本的方法
" ====================================================
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

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

標簽: ASP
相關文章:
主站蜘蛛池模板: 国产三级高清 | 国产免费高清 | 欧美日韩一级大片 | 欧美日韩在线观看成人 | 91最新国产 | 中文字幕日本一区 | 噼里啪啦国语完整在线观看高清 | 黄色a级片在线观看 | 有码在线播放 | 看特级毛片 | 色虎在线观看 | 精品性久久 | 国产精品成人一区二区网站软件 | 精品国产大片大片大片 | 水果视频污 | 国产人妖一区 | 欧美日韩中文 | 玖玖爱在线精品视频 | 日韩视频一区二区三区在线播放免费观看 | 国产精品成人国产乱一区 | 欧美欧美欧美欧美 | 国产精品久久91 | 国产免费99 | 青草视频在线 | 国产精品影音先锋 | 成人一区三区 | 美女久久久久久久久久 | 91精产国品 | 日本亚洲黄色 | 成人第一页 | 超碰在线人人 | 神马久久精品综合 | 欧美日韩中文字幕在线观看 | 亚洲理论视频 | 欧美片在线观看 | 日本中文字幕免费在线观看 | 天堂av观看 | 日本黄色片视频 | 中文字幕在线精品 | 人人插人人搞 | 黄色片网站在线观看 |