Hello, I'm currently developing an EventManager class to ensure that no events are left wired to dead WCF duplex clients, and also to control prevent multiple wiring from the same client to the one event.
Now basically, I'm what stuck with is trying to pass the event delegate to a function that will control the assignment like this.
var handler = new SomeEventHandler(MyHandler);
Wire(myObject.SomeEventDelegate, handler);
To call this:
private void Wire(Delegate eventDelegate, Delegate handler)
{
// Pre validate the subscription.
eventDelegate = Delegate.Combine(eventDelegate, handler);
// Post actions (storing subscribed event delegates in a list)
}
Update
The code for SomeEventDelegate wrapper is:
public Delegate SomeEventDelegate
{
get { return SomeEvent; }
set { SomeEvent = (SomeEventHandler) value; }
}
event SomeEventHandler SomeEvent;
Obviously the delegate is not being returned to the myObject.SomeEventDelegate And I cannot return the Delegate from the method because I need some validation after too. Do you have any idea on how to do this?
BRGDS