首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

C# 發現之旅第十四講:VB.NET 腳本引擎(上)─ ScriptText 屬性與編譯觸發機制

     編輯:關於C語言

ScriptText 屬性實作


private bool bolScriptModified = true;
private string strScriptText = null;

public string ScriptText {
    get => strScriptText;
    set {
        if (strScriptText != value) {
            bolScriptModified = true;
            strScriptText = value;
        }
    }
}
  • 設定新腳本文字時標記 bolScriptModified = true
  • 執行腳本前檢查此旗標,決定是否重新編譯

其他控制屬性


private bool bolEnabled = true;
public bool Enabled { get => bolEnabled; set => bolEnabled = value; }

private bool bolOutputDebug = true;
public bool OutputDebug { get => bolOutputDebug; set => bolOutputDebug = value; }
  • Enabled:整體啟用/停用腳本引擎
  • OutputDebug:控制編譯/執行過程偵錯輸出

Compile 方法職責

封裝三大步驟:

  1. 生成腳本代碼文字 (strRuntimeSource)
  2. 動態編譯產生臨時組件
  3. 分析組件快取腳本方法資訊

供外部呼叫或內部自動觸發(bolScriptModified 為真時)。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved