Search Results

Search found 1 results on 1 pages for 'stretto'.

Page 1/1 | 1 

  • Events + Adapter Pattern

    - by Stretto
    I have an adapter pattern on a generic class that essentially adapts between types: class A<T> { event EventHandler e; } class Aadapter<T1, T2> : A<T1> { A<T2> a; Aadapter(A<T2> _a) { a = _a; } } The problem is that A contains an event. I effectively want all event handlers assigned to Adapter to fall through to a. It would be awesome if I could assign the a's event handler to adapter's event handler but this is impossible? The idea here is that A is almost really just A but we need a way to adapt the them. Because of the way event's work I can't how to efficiently do it except manually add two event handlers and when they are called they "relay" the to the other event. This isn't pretty though and it would seem much nicer if I could have something like class A<T> { event EventHandler e; } class Aadapter<T1, T2> : A<T1> { event *e; A<T2> a; Aadapter(A<T2> _a) { a = _a; e = a.e; } } in a sense we have a pointer to the event that we can assign a2's event to. I doubt there is any simple way but maybe someone has some idea to make it work. (BTW, I realize this is possible with virtual events but I'd like to avoid this if at all possible)

    Read the article

1