Table of Contents

Property ScriptSource

Namespace
Alternet.Scripter.IronPython
Assembly
Alternet.Scripter.IronPython.v9.dll

ScriptSource

Gets source of the script to execute.

[Browsable(false)]
public IScriptSource ScriptSource { get; }

Property Value

IScriptSource

Examples

Here is how to use a ScriptSource in the C# code:

using System.IO;
using Alternet.Common.DotNet;
using Alternet.Scripter.IronPython;

public partial class Form1 : Form
{
    private ScriptRun scriptRun;
    private void Form1_Load(object sender, EventArgs e)
    {
        scriptRun = new ScriptRun();
        scriptRun.ScriptSource.FromScriptCode(edit.Text);
        scriptRun.ScriptSource.ReferencesSearchPaths.Add(Path.GetDirectoryName(GetType().Assembly.Location));
        scriptRun.ScriptSource.ReferencedFrameworks = Framework.System | Framework.WindowsForms;
        scriptRun.ScriptSource.References.Add("ExternalAssembly.dll");
        scriptRun.ScriptSource.Imports.Add("System");
        scriptRun.ScriptSource.Imports.Add("System.Drawing");
        scriptRun.ScriptSource.Imports.Add("System.Windows.Forms");
        scriptRun.ScriptSource.Imports.Add("ExternalAssembly");
    }
}

Here is how to use a ScriptSource in the Visual Basic code:

Imports System.IO
Imports Alternet.Scripter.IronPython
Imports Alternet.Common.DotNet

Partial Public Class Form1
    Inherits Form

    Private scriptRun As ScriptRun

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        scriptRun = New ScriptRun()
        scriptRun.ScriptSource.FromScriptCode(edit.Text)
        scriptRun.ScriptSource.ReferencesSearchPaths.Add(Path.GetDirectoryName([GetType]().Assembly.Location))
        scriptRun.ScriptSource.ReferencedFrameworks = Framework.System Or Framework.WindowsForms
        scriptRun.ScriptSource.References.Add("ExternalAssembly.dll")
        scriptRun.ScriptSource.Imports.Add("System")
        scriptRun.ScriptSource.Imports.Add("System.Drawing")
        scriptRun.ScriptSource.Imports.Add("System.Windows.Forms")
        scriptRun.ScriptSource.Imports.Add("ExternalAssembly")
    End Sub
End Class

Remarks

ScriptSource specifies that the script to be executed is a simple code, list of files or Iron-python project.

Use IScriptSource to specify additional information related to the script compilation, such as search directories to look for the source files and referenced assemblies.