DotNetDelegate
Create an instance of a delegate
WSupported on Windows
|
|
|
|
delegate = new DotNetDelegate(assembly, type, object, method)
Arguments
delegate
The returned delegate instance (@DotNetDelegate).
assembly
The assembly that contains this delegate type.
type
The fully-qualified type name of the delegate, which includes the type’s namespace but not its assembly name.
object
A reference to an object that owns the specified method. (Object is ^NULL if you don’t want an instance method.)
method
The name of an instance method in object’s class.
Discussion
The DotNetDelegate constructor creates an instance of a delegate, which binds a Synergy DBL instance or static method to a delegate defined in the .NET assembly.
If .NET throws an exception, a corresponding DotNetException will be thrown.
The search for type is case-sensitive. If the type cannot be found in the specified assembly or it is not public, a “Field/Type/Property/Event not found” error ($ERR_MISSFLD) occurs. If method is not the name of an instance method within object’s class, an $ERR_MISSMETH occurs.
When the delegate function is invoked, the arguments passed to it will correspond to the type definition for the delegate. The following conversions will occur:
- The .NET System.String and Char are converted to a Synergy string argument.
- System.Decimal, float, and double are converted to an implied-decimal argument.
- Boolean, Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, or UInt64 are converted to an integer argument.
- An enumeration is treated like an i4, and an i4 can be passed to a .NET enumeration.
- All other types are passed as a DotNetObject argument.
- If the parameter is defined as OUT for the delegate, the value of the argument is converted conversely upon return.
Examples
The example below creates a System.EventHandler delegate and stores it in an instance called button_OnClick. See Sample programs for an example in the context of a complete program.
button_OnClick = new DotNetDelegate(sys, "System.EventHandler", ^NULL, & "ns1.cls1.static_meth1")