Expression CreateDelegate(IType type, Expression source)
{
IMethod method = (IMethod)GetEntity(source);
Expression target = null;
if (method.IsStatic)
{
target = CodeBuilder.CreateNullLiteral();
}
else
{
target = ((MemberReferenceExpression)source).Target;
}
return CodeBuilder.CreateConstructorInvocation(GetConcreteType(type).GetConstructors()[0],
target,
CodeBuilder.CreateAddressOfExpression(method));
}