Private Sub Event_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) MessageBox.Show("Hello !") End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim aPlug As Object = Button1 If aPlug.GetType().GetMethod("OpenDoor") Is Nothing Then MessageBox.Show("La methode OpenDoor n'existe pas.") Else MessageBox.Show("La methode OpenDoor existe bien !!!") End If If aPlug.GetType().GetMethod("Select") Is Nothing Then MessageBox.Show("La methode Select n'existe pas.") Else MessageBox.Show("La methode Select existe bien !!!") End If Dim tEvent As Reflection.EventInfo = aPlug.GetType().GetEvent("Click") If tEvent Is Nothing Then MessageBox.Show("L'evenement Click n'existe pas.") Else MessageBox.Show("L'evenement Click existe bien !!!") Dim tEventType As Type = tEvent.EventHandlerType aPlug.GetType().GetEvent("Click").AddEventHandler(aPlug, [Delegate].CreateDelegate(tEventType, Me, "Event_Click")) End If End Sub
Public Class f_main Public Event PutInQueuelist(ByVal handledres As ArrayList) Private Sub BGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BGo.Click dim arrHandleResults as new arraylist RaiseEvent PutInQueuelist(arrHandleResults) End Sub End class
Public Class Plugin Public Event OnDocumentToPutInQueuelist(ByVal documents As ArrayList) Public Sub Event_PutInQueuelist(ByVal handledres As ArrayList) RaiseEvent OnDocumentToPutInQueuelist(handledres) End Sub End Class
Dim pluginObj As New Plugin Dim f_mainType As Type = SRA.GetType(SRA.GetName.Name & ".f_main", False, True) Dim tEvent As Reflection.EventInfo = f_mainType.GetEvent("PutInQueuelist") If tEvent IsNot Nothing Then Dim tEventType As Type = tEvent.EventHandlerType tEvent.AddEventHandler(pluginObj, [Delegate].CreateDelegate(tEventType, pluginObj, "Event_PutInQueuelist")) End If
Public Event PutInQueuelist(ByVal handledres As ArrayList)
Public Event OnDocumentToPutInQueuelist(ByVal documents As ArrayList)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim tEventType As Type = tEvent.EventHandlerType Dim tEventDeleguate As [Delegate] = [Delegate].CreateDelegate(tEventType, pluginObj, "Event_PutInQueuelist") tEvent.AddEventHandler(pluginObj, tEventDeleguate)