-
Notifications
You must be signed in to change notification settings - Fork 37
002 Data Types
It is possible to expose any .NET type or its instance to S#. There are however common .NET types available for script by default:
Type Name | .NET Type | Initializer |
---|---|---|
double | double |
x = 1.23; x = 1.23d;
|
long | long | x = 3; |
string | string | s = 'Hello World'; |
bool | bool | b = true; |
array | object[] | a = [1, 1+2, 'Hello', s] |
There is also an implicit type object which is basically alias for .NET System.Object
. The list of base types may be changed through XML configuration. However, it does not mean that run-time can't access other .NET types. In contrast, base types are cached by alias and may be accessed faster that other types. Consider adding custom types to RuntimeHost
to improve performance of script execution.
Note: S# runtime infrastructure allows to filter types and whole assemblies available to the client scripts. It is also possible to mark members of a class definition with
[Promote(false)]
attribute to make them invisible to the default script binder.
Any type visible to the runtime can be accessed either by short name:
b = new StringBuilder();
or by its full name:
b = new System.Text.StringBuilder();
Besides the XML configuration, it is also possible to expose any .NET Framework type to the S# programs and use it within a script via the RuntimeHost.AddType()
method.
Note: If a type was not explicitly added, the S# runtime will search it in libraries loaded in the current application domain. Although it is possible to filter assemblies and types available to the script as well as completely override the assembly/type management through a custom implementation of the
IAssemblyManager
interface.