using System;
namespace Delegate
{
class Hoge
{
public EventHandler Piyo;
public Hoge() { }
public void Raise() { Piyo(null, EventArgs.Empty); }
}
class Program
{
static void Main()
{
Hoge hoge = new Hoge();
hoge.Piyo += Hoge1;
hoge.Piyo += Hoge2;
hoge.Piyo += Hoge3;
hoge.Raise();
var mcd = (MulticastDelegate)hoge.Piyo;
var list = mcd.GetInvocationList();
}
static void Hoge1(object sender, EventArgs e) { System.Diagnostics.Debug.Print("Hope1"); }
static void Hoge2(object sender, EventArgs e) { System.Diagnostics.Debug.Print("Hope2"); }
static void Hoge3(object sender, EventArgs e) { System.Diagnostics.Debug.Print("Hope3"); }
}
}
dXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIERlbGVnYXRlCnsKCWNsYXNzIEhvZ2UKCXsKCQlwdWJsaWMgRXZlbnRIYW5kbGVyIFBpeW87CgkJcHVibGljIEhvZ2UoKSB7IH0KCQlwdWJsaWMgdm9pZCBSYWlzZSgpIHsgUGl5byhudWxsLCBFdmVudEFyZ3MuRW1wdHkpOyB9Cgl9CgoJY2xhc3MgUHJvZ3JhbQoJewoJCXN0YXRpYyB2b2lkIE1haW4oKQoJCXsKCQkJSG9nZSBob2dlID0gbmV3IEhvZ2UoKTsKCQkJaG9nZS5QaXlvICs9IEhvZ2UxOwoJCQlob2dlLlBpeW8gKz0gSG9nZTI7CgkJCWhvZ2UuUGl5byArPSBIb2dlMzsKCQkJaG9nZS5SYWlzZSgpOwoKCQkJdmFyIG1jZCA9IChNdWx0aWNhc3REZWxlZ2F0ZSlob2dlLlBpeW87CgkJCXZhciBsaXN0ID0gbWNkLkdldEludm9jYXRpb25MaXN0KCk7CgkJfQoKCQlzdGF0aWMgdm9pZCBIb2dlMShvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkgeyBTeXN0ZW0uRGlhZ25vc3RpY3MuRGVidWcuUHJpbnQoIkhvcGUxIik7IH0KCQlzdGF0aWMgdm9pZCBIb2dlMihvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkgeyBTeXN0ZW0uRGlhZ25vc3RpY3MuRGVidWcuUHJpbnQoIkhvcGUyIik7IH0KCQlzdGF0aWMgdm9pZCBIb2dlMyhvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkgeyBTeXN0ZW0uRGlhZ25vc3RpY3MuRGVidWcuUHJpbnQoIkhvcGUzIik7IH0KCX0KfQo=