Class ScriptWrapper
Provides helpers to wrap and unwrap user scripts with language-specific boilerplate, namespaces, using/import directives, and event handler wiring.
Inheritance
Inherited Members
Namespace: Syncfusion.Scripting.Design
Assembly: Syncfusion.Scripting.Windows.dll
Syntax
public class ScriptWrapper
Constructors
ScriptWrapper()
Declaration
public ScriptWrapper()
Methods
AddEventSubscriptionToScript(ScriptLanguages, String, String, String)
Inserts event subscription code into a method body; creates the method if it does not exist.
Declaration
public static string AddEventSubscriptionToScript(ScriptLanguages language, string scriptcode, string methodname, string eventscript)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target language. |
| System.String | scriptcode | The full script code to modify. |
| System.String | methodname | The method name where the subscription will be inserted. |
| System.String | eventscript | The subscription code to insert. |
Returns
| Type | Description |
|---|---|
| System.String | The modified script code. |
GetEventHandlerScript(ScriptLanguages, String, String, String)
Builds an event handler method for a known event and argument type.
Declaration
public static string GetEventHandlerScript(ScriptLanguages language, string classname, string eventname, string argsType)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target script language. |
| System.String | classname | The class name hosting the handler. |
| System.String | eventname | The event name. |
| System.String | argsType | The event args type name. |
Returns
| Type | Description |
|---|---|
| System.String | Handler code for the given language. |
GetEventHandlerScriptByType(ScriptLanguages, String, EventInfo)
Builds an event handler method signature for the event specified by reflection metadata.
Declaration
public static string GetEventHandlerScriptByType(ScriptLanguages language, string classname, EventInfo evInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target script language. |
| System.String | classname | The class name hosting the handler. |
| System.Reflection.EventInfo | evInfo | The event to create a handler for. |
Returns
| Type | Description |
|---|---|
| System.String | Handler code for the given language. |
GetEventSubscriberScript(ScriptLanguages, String, String, String, EventInfo)
Builds subscription code that wires the handler to the event.
Declaration
public static string GetEventSubscriberScript(ScriptLanguages language, string nmespace, string scriptclass, string classname, EventInfo evinfo)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target script language. |
| System.String | nmespace | The namespace containing the Global class for C#. |
| System.String | scriptclass | The wrapper class name. |
| System.String | classname | The event source class name. |
| System.Reflection.EventInfo | evinfo | The event metadata. |
Returns
| Type | Description |
|---|---|
| System.String | Subscription code for the given language. |
GetEventUnsubscriberScript(ScriptLanguages, String, String, String, EventInfo)
Builds unsubscription code that detaches the handler from the event.
Declaration
public static string GetEventUnsubscriberScript(ScriptLanguages language, string nmespace, string scriptclass, string classname, EventInfo evinfo)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target script language. |
| System.String | nmespace | The namespace containing the Global class for C#. |
| System.String | scriptclass | The wrapper class name. |
| System.String | classname | The event source class name. |
| System.Reflection.EventInfo | evinfo | The event metadata. |
Returns
| Type | Description |
|---|---|
| System.String | Unsubscription code for the given language. |
GetLanguageKeywords(ScriptLanguages, out String, out String, out String, out String, out String)
Returns language-specific keywords and delimiters used when wrapping code.
Declaration
public static void GetLanguageKeywords(ScriptLanguages language, out string usingWord, out string usingDelimiter, out string classHeader, out string classFooter, out string inheritDelimiter)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target language. |
| System.String | usingWord | Outputs the using/import keyword. |
| System.String | usingDelimiter | Outputs the delimiter used to separate imports. |
| System.String | classHeader | Outputs the class header template. |
| System.String | classFooter | Outputs the class footer template. |
| System.String | inheritDelimiter | Outputs the inherits/extends delimiter. |
GetNewMethodScript(ScriptLanguages, String)
Builds an empty method for the specified language.
Declaration
public static string GetNewMethodScript(ScriptLanguages language, string methodname)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The target language. |
| System.String | methodname | The method name. |
Returns
| Type | Description |
|---|---|
| System.String | Empty method text for the given language. |
GetUnwrappedScript(ScriptLanguages, String, ref String, ref String, ref String, String, String)
Extracts raw script from a wrapped unit, returning the inner class body and separating namespace, directives, and global code.
Declaration
public static string GetUnwrappedScript(ScriptLanguages language, string script, ref string namespacedirective, ref string directives, ref string globalcode, string classname, string baseclassname)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | The script language. |
| System.String | script | The full wrapped code. |
| System.String | namespacedirective | Outputs the detected namespace name. |
| System.String | directives | Outputs collected using/import directives. |
| System.String | globalcode | Outputs remaining code outside the class (if any). |
| System.String | classname | The class name used to detect the wrapper. |
| System.String | baseclassname | The base class name (currently unused). |
Returns
| Type | Description |
|---|---|
| System.String | The unwrapped inner script body. |
GetWrappedScript(ScriptLanguages, String, String, String, String, String, String)
Wraps plain script code into a full compilable unit for the specified language, including using/imports, namespace, and class wrapper.
Declaration
public static string GetWrappedScript(ScriptLanguages language, string script, string namespacedirective, string directives, string globalcode, string classname, string baseclassname)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptLanguages | language | Target script language. |
| System.String | script | Raw script source to wrap. |
| System.String | namespacedirective | Optional namespace name to wrap the class in. |
| System.String | directives | Prepend using/import directives. |
| System.String | globalcode | Additional global code to append after the class. |
| System.String | classname | Class name placeholder to substitute. |
| System.String | baseclassname | Base class name (currently unused). |
Returns
| Type | Description |
|---|---|
| System.String | Wrapped, compilable script text. |