[C#][Reflection] Comment utiliser System.Type ?
Bonjour,
J'écrit un petit bout de code qui vise à désabonner des evenements.
Bref dans ma naïveté de débutant j'ai écrit cela
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
class RegisteredEventManager
{
public RegisteredEventManager()
{
}
private class RegisteredEvent
{
private Type pType;
private System.Delegate pEvent;
private object pAttachedMethod;
public RegisteredEvent(Type T, System.Delegate Event, object AttachedMethod)
{
this.pType = T;
this.pEvent = Event;
this.pAttachedMethod = AttachedMethod;
}
public void Unregister()
{
(this.pType)this.pEvent -= this.pAttachedMethod;
}
}
} |
Mais comme vous l'aurez déja deviné cette ligne
Code:
(this.pType)this.pEvent -= this.pAttachedMethod;
ne fonctionne pas...
Je comprend bien pourquoi, mais je n'ai pas encore trouvé le moyen
d'y palier.
Aussi me demandais je si une âme charitable m'aiderai à résoudre
ce petit problème.
Merci, Bye