private static Dispatcher CreateMethodDispatcher(object target, string name, object[] args)
{
var duck = target as IQuackFu;
if (null != duck)
return (o, arguments) => ((IQuackFu) o).QuackInvoke(name, arguments);
var type = target as Type;
if (null != type)
// static method
return DoCreateMethodDispatcher(null, type, name, args);
var targetType = target.GetType();
if (targetType.IsCOMObject)
{
// COM methods cant be seen through reflection
// so maybe the proper way to support parameter conversions
// is indeed by creating a specific Binder object
// which knows the boo conversion rules
return
(o, arguments) => o.GetType().InvokeMember(name, InvokeBindingFlags, null, target, arguments);
}
return DoCreateMethodDispatcher(target, targetType, name, args);
}