C#,分配内部委托

问题描述

我在外部程序集中有此代码

internal class StylePropertyReader
{
    internal delegate int GetCursorIdFunction(StyleSheet sheet,StyleValueHandle handle);
    internal static GetCursorIdFunction getCursorIdFunc = null;
}

其中 StyleSheet 是公共类型,StyleValueHandle 是内部类型。

我想更改 getCursorIdFunc 变量的值,如下所示:

StylePropertyReader.getCursorIdFunc = myCustomMethod;

我认为我可以通过反射轻松更改其值,但我不知道如何声明我的方法以满足内部委托,因为第二个参数类型不可访问。

如何处理第二个参数?对我来说理想的解决方案是简单地使用 object 作为类型:

static int myCustomMethod(StyleSheet sheet,object handle)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)