.NET and the Expression Editor (Magic xpa 3.x)
You can directly type .NET code into the Expression Editor by using the DotNet expression prefix to directly refer to objects defined in the defined assemblies, without the need to define a variable for them, such as: DotNet.System.something.
In the Expression Editor, press Ctrl+Space to open a list of functions. In this list, you will find the DotNet expression prefix as shown in the image below.
Once you type a period (.) after a .NET object or the DotNet expression prefix, the Automatic Complete function is activated. You can manually reopen the selection list by pressing Ctrl+Space. The Automatic Complete list will show you all the relevant .NET objects, such as properties and methods.
Expressions or operations with a .NET variable or a phrase with the DotNet expression prefix, are considered to be client-side and are marked with a C.
In the Expression Editor, when you use the auto-complete function, you will come across various icons. Here is a list of some of the most frequently seen icons.
|
Namespace
|
|
Public property
|
|
Public macro
|
|
Public interface
|
|
Public class
|
|
Public enumeration
|
|
Constant inside enumeration
|
|
Public structure
|
|
Public method
|
|
Protected method
|
|
Public event
|
|
Public delegate
|
You can use the Expression Editor to:
-
Get the property value or member value of a .NET variable – You can retrieve the value of a .NET variable by simply writing the variable followed by a dot and the property name. For example: A.Text (where A is a .NET variable). Note the following:
-
Nested and static properties are supported. For example: A.Text.Length or DotNet.System.Drawing.Text.
-
Brackets [ ] for arrays are supported. You can write another expression in the brackets.
-
This reference will return the property value according to the property type.
-
In case of an error, Null() will be returned.
-
Set the property value or member value of a .NET variable using the DNSet function.
-
Invoke a .NET variable method – Invoking a .NET variable method is done by simply typing the variable followed by a dot and the method name. For example: A.ToString() (where A is a .NET variable).
-
Nested methods are supported.
-
For Out parameters in the method signature, you must use the DNRef function.
-
Brackets [ ] for arrays are supported. You can write another expression in the brackets.
-
This reference will return the value returned from the method.
-
In case of an error or a void value, Null() will be returned.
-
Passing pointers to a method is not supported. Instead, you should send the variable by reference by sending DNRef(var)
How Do I Use .NET Enums?