Hi guys,
I've been doing things a little backwards and I've now got interface
implementation from ruby running. I've also got the code ready for creating
a delegate from a proc, but I'm still missing the plumming to use it. I'm
wondering how to automatically convert proc objects into the appropriate
Delegate type. Type.InvokeMember uses a System.Reflection.Binder object to
do the actual binding, so I could subclass Binder and have it do it.
Unfortunately you cannot subclass the default binder and I'm not keen on
having to replicate whatever functionality is in it, especially as I don't
really know all of what it does.
How have you gone about this problem?
I wish there was a way to add specific parameter conversions that would be
allowed during member resolution and binding, without having to sacrifice
the properties of the default binder. All I really want is that during
parameter matching, the following would be considered (pseudo code)
if (requiredParameterType is a delegateType && actualParameter is IProc)
convertedParameter = TypedDelegateFactory.create(requiredParameterType,
actualParameter, "call')
(Type TypedDelegateFactory.create(Type delegateType, IObject obj, string
methodName) is the bit I've already got)
Suggestions?
Cheers,
Thomas
|