public Invoke ( object targetObject, string methodName ) : void | ||
targetObject | object | |
methodName | string | |
리턴 | void |
public void SimpleCaseTest() { var test1CalledCount = 0; var testObject = new TestViewModel(0, () => test1CalledCount++, s => {}); var binder = new MethodBinder(); binder.Invoke((object)testObject, "Test1"); test1CalledCount.Is(1); binder.Invoke((object)testObject, "Test1"); test1CalledCount.Is(2); //System.Threading.Thread.Sleep(3000); //キャッシュが更新されないか目視 testObject = new TestViewModel(0, () => test1CalledCount++, s => { }); binder.Invoke((object)testObject, "Test1"); test1CalledCount.Is(3); binder.Invoke((object)testObject, "Test1"); test1CalledCount.Is(4); //System.Threading.Thread.Sleep(3000); //キャッシュ辞書からメソッドキャッシュを取得するか目視 binder = new MethodBinder(); binder.Invoke((object)testObject, "Test1"); test1CalledCount.Is(5); binder.Invoke((object)testObject, "Test1"); test1CalledCount.Is(6); }
protected override void OnAttached() { var associatedObject = AssociatedObject; if (associatedObject == null) { throw new InvalidOperationException(); } base.OnAttached(); associatedObject.Closing += (sender, e) => { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (CanClose) { return; } if (CloseCanceledCallbackCommand != null && CloseCanceledCallbackCommand.CanExecute(null)) { CloseCanceledCallbackCommand.Execute(null); } if (CloseCanceledCallbackMethodTarget != null && CloseCanceledCallbackMethodName != null) { _callbackMethod.Invoke(CloseCanceledCallbackMethodTarget, CloseCanceledCallbackMethodName); } e.Cancel = true; }; }
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); } }
protected override void OnAttached() { base.OnAttached(); AssociatedObject.Closing += (sender, e) => { if (!CanClose) { if (CloseCanceledCallbackCommand != null && CloseCanceledCallbackCommand.CanExecute(null)) { CloseCanceledCallbackCommand.Execute(null); } if (CloseCanceledCallbackMethodTarget != null && CloseCanceledCallbackMethodName != null) { _callbackMethod.Invoke(CloseCanceledCallbackMethodTarget, CloseCanceledCallbackMethodName); } e.Cancel = true; } }; }