mardi 13 avril 2021

C#, assign internal delegate

I have this code in an external assembly:

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

Where StyleSheet is a public type, StyleValueHandle is internal.

I would like to change the value of the getCursorIdFunc variable, something like this:

StylePropertyReader.getCursorIdFunc = myCustomMethod;

I think I can easly change its value through Reflection but I don't know how to declare my method in order to satisfy the internal delegate, since the second parameter type is inaccessible.

How do I deal with the second parameter? The ideal solution for me would be to simply use object as type:

static int myCustomMethod(StyleSheet sheet, object handle)




Aucun commentaire:

Enregistrer un commentaire