internal VsaScriptHost( string language, string moniker, string nameSpace) { if (language == null) { throw new System.ArgumentNullException(); } if (moniker == null) { throw new System.ArgumentNullException(); } if (nameSpace == null) { throw new System.ArgumentNullException(); } try { // Store the language this._Language = language; // Create the Script Engine based on the language _CreateEngine(); // The moniker, or root moniker, // is the unique name by which a script engine is identified // Set the moniker to be something relatively unique this._VsaEngine.RootMoniker = moniker; // Create a new instance of the VSA Site this._VsaSite = new VsaSite(); this._VsaSite.CompilerErrorEvent += new CompilerErrorEventHandler(_VsaSite_CompilerErrorEvent); // Get the instance of the site this._VsaEngine.Site = this._VsaSite; // Initialize the engine this._VsaEngine.InitNew(); // Set the rootnamespace this._VsaEngine.RootNamespace = nameSpace; // Set the engine (display) name this._VsaEngine.Name = this._VsaEngine.RootNamespace; } catch (Microsoft.Vsa.VsaException e) { throw new System.ApplicationException( string.Format( ( "A VsaException occurred\n" + "ErrorCode {0}\n" ), e.ErrorCode.ToString() ) ); } try { // Create a blank codeItem if (this.Language == "JScript.NET") { this._VsaCodeItem = (Microsoft.Vsa.IVsaCodeItem) this._VsaEngine.Items.CreateItem( "ScriptCode", Microsoft.Vsa.VsaItemType.Code, Microsoft.Vsa.VsaItemFlag.Module); } else { this._VsaCodeItem = (Microsoft.Vsa.IVsaCodeItem) this._VsaEngine.Items.CreateItem( "ScriptCode", Microsoft.Vsa.VsaItemType.Code, Microsoft.Vsa.VsaItemFlag.None); } } catch (Microsoft.Vsa.VsaException e) { throw new System.ApplicationException( string.Format( ( "A VsaException occurred\n" + "ErrorCode {0}\n" ), e.ErrorCode.ToString() ) ); } // Create a reference to system this.AddReference("System", "System.dll"); // Create a reference to Windows this.AddReference("Forms", "System.Windows.Forms.dll"); // Create a reference to Drawing this.AddReference("Drawing", "System.Drawing.dll"); // Create a reference to Xml this.AddReference("Xml", "System.Xml.dll"); // Add an import to system this._AddImport("System"); // Add an import to system this._AddImport("System.Windows.Forms"); }
internal VsaScriptHost( string language, string moniker, string nameSpace) { if (language == null) throw new System.ArgumentNullException(); if (moniker == null) throw new System.ArgumentNullException(); if (nameSpace == null) throw new System.ArgumentNullException(); try { // Store the language this._Language = language; // Create the Script Engine based on the language _CreateEngine(); // The moniker, or root moniker, // is the unique name by which a script engine is identified // Set the moniker to be something relatively unique this._VsaEngine.RootMoniker = moniker; // Create a new instance of the VSA Site this._VsaSite = new VsaSite(); this._VsaSite.CompilerErrorEvent +=new CompilerErrorEventHandler(_VsaSite_CompilerErrorEvent); // Get the instance of the site this._VsaEngine.Site = this._VsaSite; // Initialize the engine this._VsaEngine.InitNew(); // Set the rootnamespace this._VsaEngine.RootNamespace = nameSpace; // Set the engine (display) name this._VsaEngine.Name = this._VsaEngine.RootNamespace; } catch (Microsoft.Vsa.VsaException e) { throw new System.ApplicationException( string.Format( ( "A VsaException occurred\n" + "ErrorCode {0}\n" ), e.ErrorCode.ToString() ) ); } try { // Create a blank codeItem if (this.Language == "JScript.NET") { this._VsaCodeItem = (Microsoft.Vsa.IVsaCodeItem) this._VsaEngine.Items.CreateItem( "ScriptCode", Microsoft.Vsa.VsaItemType.Code, Microsoft.Vsa.VsaItemFlag.Module); } else { this._VsaCodeItem = (Microsoft.Vsa.IVsaCodeItem) this._VsaEngine.Items.CreateItem( "ScriptCode", Microsoft.Vsa.VsaItemType.Code, Microsoft.Vsa.VsaItemFlag.None); } } catch (Microsoft.Vsa.VsaException e) { throw new System.ApplicationException( string.Format( ( "A VsaException occurred\n" + "ErrorCode {0}\n" ), e.ErrorCode.ToString() ) ); } // Create a reference to system this.AddReference("System", "System.dll"); // Create a reference to Windows this.AddReference("Forms", "System.Windows.Forms.dll"); // Add an import to system this._AddImport("System"); // Add an import to system this._AddImport("System.Windows.Forms"); }