/// <summary> /// Sets the script from a string /// </summary> /// <param name="scriptText">Script text</param> /// <param name="language">Script language</param> public void SetScript(string scriptText) { _isInitialized = false; // Make sure the last allocated engine is stopped. if (_engine != null) { _engine.Close(); } _scriptText = scriptText; // Initialize globale vars _globalObs.Clear(); _engine = new Microsoft.VisualBasic.Vsa.VsaEngine(); // Initialize Engine _engine.RootMoniker = "nScriptHost://VSAScript/Instance" + NewInstanceID.ToString(); _engine.Site = this; _engine.InitNew(); _engine.RootNamespace = "__Script__"; _references.Clear(); _globalObItems.Clear(); AddDefaultReferences(); // Set the script code. IVsaCodeItem item = _engine.Items.CreateItem("Code", VsaItemType.Code, VsaItemFlag.None) as IVsaCodeItem; item.SourceText = _scriptText; }
/// <summary> /// コンストラクタ /// </summary> public VBScriptVsaSite() { // 以前にコンパイルしたスクリプトコードがゴミとして残ることがある // (IVsaEngineのバグ?)のでルートモニカは毎回ユニークな名前とする vsaEngine.RootMoniker = DEFAULT_ROOT_MONIKER + Guid.NewGuid().ToString() + "/"; vsaEngine.Site = this; vsaEngine.InitNew(); vsaEngine.RootNamespace = DEFAULT_ROOT_NAME_SPACE; vsaEngine.GenerateDebugInfo = true; }