のパラメータとしてメソッドを使用する方法はInvokeMember
?つまり
反射なし
ContainerEvents ems = new ContainerEvents();
Test ob1 = new Test(4);
Exam ob2 = new Exam(1);
FExam ob3 = new FExam(1);
Check ob4 = new Check(5);
ems.Setplus = new Super(ob1.Write);
ems.Setplus = new Super(ob2.Write);
ems.Setplus = new Super(ob3.Write);
ems.Setplus = new Super(ob4.Write);
ems.Run();
スーパーは代表です。
振り返って同じことをしたい
Type type1 = typeof (Test);
Type type2 = typeof (Exam);
Type type3 = typeof (FExam);
Type type4 = typeof (Check);
Type events = typeof (ContainerEvents);
object eventer = Activator.CreateInstance(events);
events.InvokeMember("Setplus",BindingFlags.InvokeMethod,null,eventer,)
しかし、パラメータとして何を送信すればよいかわかりません。Super
オブジェクトのインスタンスを作成しますか?
Setplusはプロパティです
public Super Setplus
{
set { obj.activate += value; }
}
obj-クラスイベントのオブジェクト
public class Event
{
public event Super activate ;
public void act()
{
if (activate != null) activate();
}
}