DotNetObject.Call

Invoke methods of an instance

WTSupported in traditional Synergy on Windows

 

 

 

retval = object.Call(methodname [, arg ...])

Arguments

retval

The return value of the method (@System.Object).

object

The handle of an object returned by the DotNetObject constructor, the DotNetAssembly constructor, or some other method or property that returns an object.

methodname

The name of the method to call.

arg

One or more arguments for the method.

Discussion

Methodname must be a public or public static method defined for the specified object; otherwise, an $ERR_MISSMETH error will occur.

If a method is defined more than once using different parameters, the default binder is used to attempt to locate the best fit for the parameters passed. The binder attempts an exact match, a conversion match honoring integer variable sizes matching the same or larger types, and finally, a conversion match from any int to any int. If no match is found, an $ERR_MISSMETH error will occur.

The type and number of arguments in arg must exactly match one of the argument signatures for the method; optional arguments and variable-length argument lists are not supported.

The system attempts to convert parameters from Synergy/DE types to .NET types via an intermediate type according to the rules below:

The intermediate type is then converted by the standard .NET conversion functions as permitted by the binder. It is important to follow the .NET rules for conversions, or the .NET Framework will generate an exception. A .NET exception is also caused by the following circumstances:

To pass a null object as a parameter, use ^NULL.

Objects are returned as follows, depending on the .NET type:

Objects Returned for .NET Types

.NET type returned

Returned object

System.String

Synergy System.String

System.Decimal

Boxed Synergy implied-decimal value

One of the integer types described above

Boxed Synergy integer value of appropriate size

Any other returned .NET type

Type DotNetObject, wrapping the returned .NET object

If object is an object returned from the DotNetAssembly constructor, only static methods can be accessed using the namespace.class.method form of methodname.

Examples

The example below invokes DateTime.Parse. See Sample programs for an example in the context of a complete program.

obj2 = (DotNetObject)((DotNetObject)asm).Call("System.DateTime.Parse",
    &  "13 March 1986")