我需要从某个第三方库覆盖一个方法,然后将结果对象注入另一个第三方库。问题是该方法不是虚拟的,所以我无法覆盖它。它看起来像是使用SwapMethodBody方法的解决方案,但它没有在Mono中实现。
using System;
using System.Security.Permissions;
[MonoTODO]
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public static void SwapMethodBody (Type cls, int methodtoken, IntPtr rgIL, int methodSize, int flags)
{
if (methodSize <= 0 || methodSize >= 4128768) {
throw new ArgumentException ("Data size must be > 0 and < 0x3f0000", "methodSize");
}
if (cls == null) {
throw new ArgumentNullException ("cls");
}
if (cls is TypeBuilder && !((TypeBuilder)cls).is_created) {
throw new NotSupportedException ("Type '" + cls + "' is not yet created.");
}
throw new NotImplementedException ();
}
有什么想法吗?