|
|
|
The explicit constructor call does work but it is a little more verbose:
<snip> def click(): c = Function(null, _addressof_(click)) Notice that explicit delegate constructor calls like the one above are not type checked (meaning that the compiler will not complain if the method reference is not compatible with the delegate type). But does this solve the issue? That works - thanks. However now I've run into another related issue:
with the following code: def clicked(sender, args as System.EventArgs): clickedHandler = System.EventHandler(null, _addressof_(clicked)) c.Click += clicked # this works an explicitly created delegate handle fails on assignment with: looking at the IL for the working assignment: It is contructing an EventHandler object but doing the same in boo code give a failure. fantasitc ! - Thanks for the quick turnaround.
I'm still having this problem:
def Method(sender as object, e as EventArgs): h = EventHandler(Method) BCE0024: The type 'System.EventHandler' does not have a visible constructor that matches the argument list '(callable(System.Object, System.EventArgs) as System.Void)'. This problem currently requires an ugly hack in the C# parser (involving .EndsWith("EventHandler")...) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
L_0000: ldnull
L_0001: ldftn void DelegateTestModule::printTest(string)
L_0007: newobj instance void OutputHandler::.ctor(object, native int)
L_000c: stloc.0
L_000d: ret
OutputHandler's constructor is being called. So it would make sense that an explicit call to the constructor should also work.