/// <summary>
/// Static constructor generates acedRegisterFilterWinMsg
/// dynamically at runtime, to call the appropriate P/Invoke
/// method based on release and platform (same must be done
/// for acedRemoveFilterWinMsg, but that's not shown here):
/// </summary>
static Func<WindowHookProc, int> acedRegisterFilterWinMsg = null;
static HookESC()
{
MethodInfo target = null;
bool x64 = IntPtr.Size > 4;
if( AcadVer > 18 )
{
if( x64 )
target = ( (Func<WindowHookProc, int>)
acedRegisterFilterWinMsg2013x64 ).Method;
else
target = ( (Func<WindowHookProc, int>)
acedRegisterFilterWinMsg2013x32 ).Method;
}
else
{
if( x64 )
target = ( (Func<WindowHookProc, int>)
acedRegisterFilterWinMsg2012x64 ).Method;
else
target = ( (Func<WindowHookProc, int>)
acedRegisterFilterWinMsg2012x32 ).Method;
}
var arg
= Expression
.Parameter( typeof( WindowHookProc
),
"arg" );
acedRegisterFilterWinMsg =
Expression.Lambda<Func<WindowHookProc, int>>(
Expression.Call( target, arg ), arg ).Compile();
}