I have a problem: imagine I have a plugin-based system.
I need some kind of interface with which I could catch events from every plugin, which implements for example
Instead of (IReporting)obj.XXX you should write ((IReporting)obj).XXX
public interface IFoo
{
event EventHandler Boo;
}
class Foo : IFoo
{
public event EventHandler Boo;
public void RaiseBoo()
{
if (Boo != null)
Boo(this, EventArgs.Empty);
}
}
...
private void TestClass_Boo(object sender, EventArgs e)
{
throw new NotImplementedException();
}
...
object o = new Foo();
((IFoo)o).Boo += TestClass_Boo;
((Foo)o).RaiseBoo();
Regarding plugin framework take a look at existing solutions with good architecture, for example MEF