How do I implicitly convert a delegate to other?
// old
public delegate OldClickEventHandler(object sender, OldClickEventArgs e);
class OldClickEventArgs
{
public int intEnumValue;
OldClickEventArgs(int enumValue){ this.intEnumValue = enumValue; }
}
// new
public delegate NewClickEventHandler(object sender, NewClickEventArgs e);
class NewClickEventArgs
{
public MyEnum EnumValue;
NewClickEventArgs(MyEnum enumValue){ this.EnumValue = enumValue; }
public static implicit operator NewClickEventArgs(OldClickEventArgs e) {
return new NewClickEventArgs((MyEnum)e.intEnumValue);
}
}
// class NewButton : OldButton
// here I need to implicitly convert EventHandlers. HOW?
//
public event NewClickEventHandler Click
{
add {
oldObject.Click += value; // cannot convert New.. to Old..
}
remove {
oldObject.Click -= value; // cannot convert New.. to Old..
}
}