|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Retrieving a handle to a private delegateI have some problems when testing a system. In class A i have: Public Event CommEvent As CommEventHandler Public Delegate Sub CommEventHandler() and a method: EnableEvents(ByVal Callback As CommEventHandler) Then in class B i have Private Sub OnCommEventReceived() Handles A.CommEvent >From my test class (class C) I need to call EnableEvents with OnCommEventReceived as an argument. The problem is I do not know how toprovide a handle to OnCommEventReceived. Since OnCommEventReceived is private I guess I need to use reflection, but I cannot make it work. I have used for instance MethodInfo to invoke private methods before, but now I just need some kind of handle to the OnCommEventReceived method in class B to provide to the EnableEvents method in class A. Thank you! /Fredrik Strandberg The "addressof" operator must be used somehow or am I on the wrong
track? Fredrik Strandberg wrote:
Show quoteHide quote > Hi! Since you know how to call B.OnCommEventReceived, how about providing> > I have some problems when testing a system. > > In class A i have: > > Public Event CommEvent As CommEventHandler > Public Delegate Sub CommEventHandler() > > and a method: > > EnableEvents(ByVal Callback As CommEventHandler) > > Then in class B i have > > Private Sub OnCommEventReceived() Handles A.CommEvent > > >From my test class (class C) I need to call EnableEvents with > OnCommEventReceived as an argument. The problem is I do not know how to > provide a handle to OnCommEventReceived. Since OnCommEventReceived is > private I guess I need to use reflection, but I cannot make it work. > > I have used for instance MethodInfo to invoke private methods before, > but now I just need some kind of handle to the OnCommEventReceived > method in class B to provide to the EnableEvents method in class A. *in class C* a proxy method that has the same signature, and just calls B.OnCommEventReceived (via reflection). Then just give C.Proxy to A.EnableEvents. -- Larry Lard Replies to group please
DateTimePicker + DataBinding + Null-Value: THE solution?
Is there a simple way to email? What is Instrumentation? ptr to string ? How to remove Volume Name on removable drive? Help please Creating web page of links and content Unit Testing and Test Cases NEWBIE question multi threading error Printing a bar code |
|||||||||||||||||||||||