Create Delegates from .NET Object Methods
The following C# class defines the methodsAddEggs
andAddFlour
, which have signatures matching thedelInteger
delegate:
Build theRecipe
assembly, and then load it and create a delegatemyFunc
usingAddEggs
as the callback:
NET.addAssembly(dllPath); NET.addAssembly('c:\work\Recipe.dll');myRec = Recipe.MyClass;myFunc = NetDocDelegate.delInteger(@myRec.AddEggs); myFunc(2)
ans = Add 2 eggs