Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Module ScriptManager
- Private _scripts As New List(Of Script)
- Public Sub LoadScripts()
- For Each s In IO.Directory.GetFiles(Application.StartupPath & "\Scripts")
- _scripts.Add(New Script(s))
- Next
- End Sub
- Public Function [Get](filename As String) As Script
- For Each s In From s1 In _scripts Where s1.Filename = filename
- Return s
- Next
- Return Nothing
- End Function
- Public Sub Run(scriptname As String, method As String, ParamArray arguments As Object())
- For Each l In _scripts
- If l.Extension = ".vb" Or l.Extension = ".cs" Then
- Dim engine As New rScripting.CompileEngine(l.Extension)
- If l.Extension = ".vb" Then
- engine.Compiler = "vb"
- Else
- engine.Compiler = "C#"
- End If
- engine.AddAssemblyReference("System.dll")
- engine.AddAssemblyReference("System.Core.dll")
- engine.AddAssemblyReference("System.Deployment.dll")
- engine.AddAssemblyReference("System.Windows.Forms.dll")
- engine.AddAssemblyReference("System.Drawing.dll")
- engine.AddAssemblyReference(Application.StartupPath & "\DotNetLib.dll")
- engine.AddAssemblyReference(Application.StartupPath & "\Calculator.exe")
- engine.AddAssemblyReference(Application.StartupPath & "\NeturalMath.dll")
- l.compiled = engine.Compile({l.content})
- If engine.HasErrors Then
- MsgBox(engine.Errors)
- End If
- If l.compiled Then
- Dim obj As New rScripting.LateBinding.ScriptFactory(engine.CompiledAssembly)
- obj.GetScript(scriptname).InvokeMethod(method, arguments)
- End If
- End If
- Next
- End Sub
- End Module
- Public Class Script
- Sub New(script As String)
- Filename = script
- Extension = IO.Path.GetExtension(script)
- content = My.Computer.FileSystem.ReadAllText(script)
- End Sub
- Public Property Extension As String = ".cs"
- Public Property Filename As String = ""
- Public Property content As String = ""
- Public Property compiled As Boolean = False
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement