Please note that the ad declaration you use is a short notation in C #:
public event EventHandler Event; public void RaiseEvent() { this.Event(this, new EventArgs()); }
It is equivalent to:
private EventHandler backEndStorage; public event EventHandler Event { add { this.backEndStorage += value; } remove { this.backEndStorage -= value; } } public void RaiseEvent() { this.backEndStorage(this, new EventArgs()); }
If backEndStorage is a multi-sheet delegate.
Now you can rewrite your code:
public interface IFoo { event EventHandler<FooEventArgs> FooValueChanged; void RaiseFooValueChanged(IFooView sender, FooEventArgs e); } [TypeDescriptionProvider(typeof(FooBaseImplementor))] public abstract class FooBase : Control, IFoo { protected event EventHandler<FooEventArgs> backEndStorage; public event EventHandler<FooEventArgs> FooValueChanged { add { this.backEndStorage += value; } remove { this.backEndStorage -= value; } } public void RaiseFooValueChanged(IFooView sender, FooEventArgs e) { this.backEndStorage(sender, e); } } public class FooDerived : FooBase { public event EventHandler<FooEventArgs> AnotherFooValueChanged { add { this.backEndStorage += value; } remove { this.backEndStorage -= value; } } }
So now that events are added to the derived class, they will actually be added to the backEndStorage of the base class, therefore, allowing the base class to call delegates registered in the derived class.
source share