public class NDelegate
extends java.lang.Object
NObject sample = Javonet.New("ClassWithDel");
sample.invoke("Execute",new NDelegate("VoidCallback") {
@Override
public void delegateCalled(Object[] arguments) {
System.out.println("Delegate Called on JAVA Side arg1:"+arguments[0]);
}
});
You can also pass NDelegate as argument to constructor for example while initializing System.Thread.Thread object.
NObject thread = Javonet.New("Thread", new NDelegate("ThreadStart") {
@Override
public void delegateCalled(Object[] arguments) {
//Your JAVA code to be invoked when .NET thread is started
}
});
thread.invoke("Start");
Constructor and Description |
---|
NDelegate(NType delegateType)
Creates new instance of delegate handler using delegate type provided as NType.
|
NDelegate(java.lang.String delegateType)
Creates new instance of delegate handler using delegate type provided as string.
|
Modifier and Type | Method and Description |
---|---|
static void |
CallDelegate(java.lang.String objectId,
java.lang.Object[] arguments)
Internal method used to route the delegate call.
|
void |
delegateCalled(java.lang.Object[] arguments)
Method called when .NET code invokes delegate on which this instance of NDelegate
was assigned.
|
java.lang.String |
getDelegateType()
Returns the type name of delegate used to initialize this delegate handler.
|
NType |
getDelegateTypeObj()
Returns the type of delegate used to initialize this delegate handler.
|
java.lang.String |
getOid()
Returns unique identifier of delegate instance.
|
public NDelegate(NType delegateType)
delegateType
- delegate type provided as NType object.public NDelegate(java.lang.String delegateType)
delegateType
- delegate type name with or without namespace.public static void CallDelegate(java.lang.String objectId, java.lang.Object[] arguments)
objectId
- unique identifier of NDelegate instancearguments
- arguments passed during the invocation of delegate on .NET side.public void delegateCalled(java.lang.Object[] arguments)
arguments
- arguments passed to delegate on .NET side when delegate was invoked. Arguments are stored in Object array in the same sequence as they were passed to delegate. These can be any JAVA primitive types (integer, string, float..) or instances of NObject class for reference-type arguments.public java.lang.String getDelegateType()
NObject thread = Javonet.New("Thread", new NDelegate("ThreadStart") {
{@literal @}Override
public void delegateCalled(Object[] arguments) {
//Your JAVA code that will be execute when .NET Thread is started
}
});
public NType getDelegateTypeObj()
public java.lang.String getOid()