public Invoke ( object targetObject, string methodName, object argument ) : void | ||
targetObject | object | |
methodName | string | |
argument | object | |
Результат | void |
public void SimpleCaseTest2() { var test2CalledCount = 0; string test2Argument = null; var testObject = new TestViewModel(0, () => { }, s => { test2CalledCount++; test2Argument = s; }); var binder = new MethodBinderWithArgument(); binder.Invoke((object)testObject, "Test2","a"); test2CalledCount.Is(1); test2Argument.Is("a"); binder.Invoke((object)testObject, "Test2","b"); test2CalledCount.Is(2); test2Argument.Is("b"); //System.Threading.Thread.Sleep(3000); //キャッシュが更新されないか目視 testObject = new TestViewModel(0, () => { }, s => { test2CalledCount++; test2Argument = s; }); binder.Invoke((object)testObject, "Test2", "a"); test2CalledCount.Is(3); test2Argument.Is("a"); binder.Invoke((object)testObject, "Test2", "b"); test2CalledCount.Is(4); test2Argument.Is("b"); //System.Threading.Thread.Sleep(3000); //キャッシュ辞書からメソッドキャッシュを取得するか目視 binder = new MethodBinderWithArgument(); binder.Invoke((object)testObject, "Test2", "a"); test2CalledCount.Is(5); test2Argument.Is("a"); binder.Invoke((object)testObject, "Test2", "b"); test2CalledCount.Is(6); test2Argument.Is("b"); }
protected override void Invoke(object parameter) { if (MethodTarget == null) { return; } if (MethodName == null) { return; } if (!_parameterSet) { _method.Invoke(MethodTarget, MethodName); } else { _callbackMethod.Invoke(MethodTarget, MethodName, MethodParameter); } }