Hi, I'm restructuring opur code to use generics. We do use (out of necessity, no changes possible here) own code to attach/detach/iterate/calls delegates. Before there were classes X, Y, Z which declared their own:
public delegate void Event_x_Delegate(ref ComParam pVal, out bool result);
At the moment I'm passing this delegate to the generic class:
public sealed class Event_X_Handling : BasicEvent<Event_X_Handling.Event_x_Delegate>
with the BasicEvent beeing
public abstract class BasicEvent<DELEGATE> : Loggable
where DELEGATE: class { ...
This works just fine, so I had the attach/detach-functionality generalized.
But now I'd like to generalize the iteration/calling too. As X,Y,Z only differ in the "ref ComParam pVal" something like this works nice:
public abstract class BasicEventListener<EVENTPARAM1> :
BasicEvent<BasicEventListener<EVENTPARAM1>.BasicDelegate<EVENTPARAM1>> {
#region TYPES
public delegate void BasicDelegate<PARAM1>(ref EVENTPARAM1 pVal, out bool result);
#endregion
with X,Y,Z changing to:
public sealed class Event_X_Handling : BasicEventListener<ComParam>
But here comes the problem lurking around the corner: attach/detach now work with a BasicEventListener.BasicDelegate. But a lot of code. refers to Event_X_Handling.Event_x_Delegate, as they unfortunately used the NET1.1-syntax for creating delegates (beeing a typed Event += new Delegate_X(_listen)).
So in short: is there a way to alias an Event_x_Delegate to a BasicDelegate? I can't really see any other possibilities.
PS: Of course I see that with breaking the base classes down to dynamic invocation in the iterating/calling I could implement it without introducing the BasicDelegate. But this is not very elegant IMHO.