Class Script
Encapsulates the source code, references, and global instances of a script.
Implements
Inherited Members
Namespace: Syncfusion.Scripting
Assembly: Syncfusion.Scripting.Base.dll
Syntax
public class Script : ISerializable
Remarks
A script consists of source code, assembly references, global instances, and event sources. A script also has a name associated with it.
Constructors
Script()
Default constructor
Declaration
public Script()
Script(SerializationInfo, StreamingContext)
Serialization constructor for script objects.
Declaration
protected Script(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | Serialization state information |
System.Runtime.Serialization.StreamingContext | context | Streaming context information |
Script(String)
Construct a script with the given source code.
Declaration
public Script(string sourceText)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | Source code to assign to the script |
Fields
DEFAULT_ASSEMBLIES
List of assemblies attached automatically to engine on execution
Declaration
public static readonly string[] DEFAULT_ASSEMBLIES
Field Value
Type |
---|
System.String[] |
Properties
AssemblyReferences
Names of assemblies referenced by the script.
Declaration
public AssemblyDescriptorCollection AssemblyReferences { get; }
Property Value
Type |
---|
AssemblyDescriptorCollection |
EntryPoint
The starting method that will be called when the script is run.
Declaration
public string EntryPoint { get; set; }
Property Value
Type |
---|
System.String |
Remarks
If this property is null, then no method is called when the script is started. It is null by default.
EventsEnabled
Flag indicating if firing of events is enabled.
Declaration
public bool EventsEnabled { get; set; }
Property Value
Type |
---|
System.Boolean |
EventSources
Names of event sources referenced by the script.
Declaration
public ScriptObjectCollection EventSources { get; }
Property Value
Type |
---|
ScriptObjectCollection |
GlobalInstances
Names of global instances declared by the script.
Declaration
public ScriptObjectCollection GlobalInstances { get; }
Property Value
Type |
---|
ScriptObjectCollection |
Language
Script language that the source code is written in.
Declaration
public ScriptLanguages Language { get; set; }
Property Value
Type |
---|
ScriptLanguages |
Name
Name of the script.
Declaration
public string Name { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Name of the script must be the same as name of the class in the script source.
RootMoniker
Root moniker for the script.
Declaration
public string RootMoniker { get; set; }
Property Value
Type |
---|
System.String |
Remarks
The moniker, or root moniker, is the unique name by which a script engine is identified. However, an engine may throw a RootMonikerInUse exception if it detects that the moniker you are attempting to assign it is already assigned to another script engine. The root moniker cannot exceed 256 characters in length. By default this property is constructed from RootNamespace and Name property. If you use several scripts on the same host, be sure that RootNamespace or Name properties are different.
RootNamespace
Root namespace for declarations in the script.
Declaration
public string RootNamespace { get; set; }
Property Value
Type |
---|
System.String |
ScriptStartCall
The ScriptStartCall method is invoked right after the script is started.
Declaration
public string ScriptStartCall { get; set; }
Property Value
Type |
---|
System.String |
ScriptStopCall
The ScriptStopCall method is invoked just before the script is stopped.
Declaration
public string ScriptStopCall { get; set; }
Property Value
Type |
---|
System.String |
SetNameFromSource
Gets or sets if parsing of source text and assigning of Name property by class name is required or not.
Declaration
public bool SetNameFromSource { get; set; }
Property Value
Type |
---|
System.Boolean |
SourceText
Source code for the script.
Declaration
public string SourceText { get; set; }
Property Value
Type |
---|
System.String |
Methods
AddEventSource(String, String)
Adds an event source to the script.
Declaration
public bool AddEventSource(string name, string typeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of event source to add |
System.String | typeName | Type of event source as a string |
Returns
Type | Description |
---|---|
System.Boolean | true if added successfully; false if it already exists |
AddGlobalInstance(String, String)
Adds a global instance to the script.
Declaration
public bool AddGlobalInstance(string name, string typeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of global instance to add |
System.String | typeName | Type of global instance as a string |
Returns
Type | Description |
---|---|
System.Boolean | true if added successfully; false if it already exists |
AddReference(AssemblyDescriptor)
Adds the specified assembly reference to the script.
Declaration
public bool AddReference(AssemblyDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
AssemblyDescriptor | descriptor | The AssemblyDescriptor representing the assembly. |
Returns
Type | Description |
---|---|
System.Boolean | true if successfully added; false if the assembly reference already exists in the script |
ContainsEventSource(String)
Indicates if the specified event source exists in the script.
Declaration
public bool ContainsEventSource(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of global instance to search for |
Returns
Type |
---|
System.Boolean |
ContainsGlobalInstance(String)
Indicates if the specified global instance exists in the script.
Declaration
public bool ContainsGlobalInstance(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of global instance to search for |
Returns
Type |
---|
System.Boolean |
ContainsReference(AssemblyDescriptor)
Determines if the script contains the specified assembly reference.
Declaration
public bool ContainsReference(AssemblyDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
AssemblyDescriptor | descriptor | The AssemblyDescriptor representing the assembly. |
Returns
Type | Description |
---|---|
System.Boolean | true if script contains a reference to the assembly; otherwise false |
GetEventSources(ScriptObjectCollection)
Declaration
public void GetEventSources(ScriptObjectCollection eventSources)
Parameters
Type | Name | Description |
---|---|---|
ScriptObjectCollection | eventSources |
GetGlobalInstances(ScriptObjectCollection)
Declaration
public void GetGlobalInstances(ScriptObjectCollection globalInstances)
Parameters
Type | Name | Description |
---|---|---|
ScriptObjectCollection | globalInstances |
GetObjectData(SerializationInfo, StreamingContext)
Declaration
protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | |
System.Runtime.Serialization.StreamingContext | context |
GetReferences(AssemblyDescriptorCollection)
Declaration
public void GetReferences(AssemblyDescriptorCollection assemblyreferences)
Parameters
Type | Name | Description |
---|---|---|
AssemblyDescriptorCollection | assemblyreferences |
InvokeMethod(IVsaEngine, String)
Declaration
public object InvokeMethod(IVsaEngine scriptEngine, string methodName)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Vsa.IVsaEngine | scriptEngine | |
System.String | methodName |
Returns
Type |
---|
System.Object |
LoadScriptEngineItems(IVsaEngine)
Declaration
public bool LoadScriptEngineItems(IVsaEngine scriptengine)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Vsa.IVsaEngine | scriptengine |
Returns
Type |
---|
System.Boolean |
LoadSource(Stream)
Loads the given stream into the script.
Declaration
public void LoadSource(Stream strm)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | strm | Stream containing the script source |
LoadSourceFile(String)
Loads the contents of the specified file into the script.
Declaration
public void LoadSourceFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of file containing the script source |
OnChanged(ScriptEventArgs)
Called when the script is changed.
Declaration
protected virtual void OnChanged(ScriptEventArgs evtArgs)
Parameters
Type | Name | Description |
---|---|---|
ScriptEventArgs | evtArgs |
OnSourceTextChanged(ScriptEventArgs)
Raises when source text has been changed.
Declaration
protected virtual void OnSourceTextChanged(ScriptEventArgs evtArgs)
Parameters
Type | Name | Description |
---|---|---|
ScriptEventArgs | evtArgs |
PutEventSources(ScriptObjectCollection)
Declaration
public void PutEventSources(ScriptObjectCollection eventSources)
Parameters
Type | Name | Description |
---|---|---|
ScriptObjectCollection | eventSources |
PutGlobalInstances(ScriptObjectCollection)
Declaration
public void PutGlobalInstances(ScriptObjectCollection globalInstances)
Parameters
Type | Name | Description |
---|---|---|
ScriptObjectCollection | globalInstances |
PutReferences(AssemblyDescriptorCollection)
Declaration
public void PutReferences(AssemblyDescriptorCollection assemblyreferences)
Parameters
Type | Name | Description |
---|---|---|
AssemblyDescriptorCollection | assemblyreferences |
SaveSourceFile(String)
Saves the script source text into the specified file.
Declaration
public void SaveSourceFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of file to save source into |
ToString()
Declaration
public override string ToString()
Returns
Type |
---|
System.String |
Overrides
Events
Changed
Fired when the script is changed.
Declaration
public event ScriptEventHandler Changed
Event Type
Type |
---|
ScriptEventHandler |
Explicit Interface Implementations
ISerializable.GetObjectData(SerializationInfo, StreamingContext)
Declaration
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | |
System.Runtime.Serialization.StreamingContext | context |