Expression Adapt(ICallableType expected, Expression callable)
{
ICallableType actual = GetExpressionType(callable) as ICallableType;
if (null == actual)
{
// TODO: should we adapt System.Object, System.Delegate,
// System.MulticastDelegate and ICallable as well?
return null;
}
ClassDefinition adaptor = GetAdaptor(expected, actual);
Method adapt = (Method)adaptor.Members["Adapt"];
return CodeBuilder.CreateMethodInvocation((IMethod)adapt.Entity, callable);
}