接口强制执行事件,任何东西强制执行处理程序?

时间:2016-11-24 00:10:59

标签: c#

假设:

public delegate void MyHandler(object sender, EventArgs<SomeArgs> e)

public interface MyInterface
{
    event MyHandler TheEvent;
} 

class MyClass:MyInterface
{
    public event MyHandler TheEvent;         
}

class TheProblemClass:FrameworkElement //, IPossibleInterface?
{
    public MyClass Instance1{get;set;}
    public MyClass Instance2{get;set;}

    //You used an instance of MyClass, now you must handle Instance1.TheEvent
    //You used another instance of MyClass, now you must handle must handle Instance2.TheEvent
    //...for any instance of MyClass, MUST handle TheEvent

}

好的,所以我打算让其他开发人员使用MyClass的实例创建自己的类。有什么方法可以强制声明MyClass实例的范围来处理事件吗?

0 个答案:

没有答案