本文整理汇总了C#中Subject.InvokeCommand方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.InvokeCommand方法的具体用法?C# Subject.InvokeCommand怎么用?C# Subject.InvokeCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.InvokeCommand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecuteWindow
public void InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecuteWindow()
{
var executed = false;
var canExecute = new BehaviorSubject<bool>(false);
var fixture = new ReactiveCommandHolder();
var source = new Subject<int>();
source.InvokeCommand(fixture, x => x.TheCommand);
fixture.TheCommand = ReactiveCommand.Create<int>(_ => executed = true, canExecute);
source.OnNext(0);
Assert.False(executed);
// The execution window re-opens, but the above execution request should not be instigated because
// it occurred when the window was closed. Execution requests do not queue up when the window is closed.
canExecute.OnNext(true);
Assert.False(executed);
}
示例2: InvokeCommandAgainstReactiveCommandInTargetPassesTheSpecifiedValueToExecute
public void InvokeCommandAgainstReactiveCommandInTargetPassesTheSpecifiedValueToExecute()
{
var executeReceived = 0;
var fixture = new ReactiveCommandHolder();
var source = new Subject<int>();
source.InvokeCommand(fixture, x => x.TheCommand);
fixture.TheCommand = ReactiveCommand.Create<int>(x => executeReceived = x);
source.OnNext(42);
Assert.Equal(42, executeReceived);
}
示例3: InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecute
public void InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecute()
{
var executed = false;
var canExecute = new BehaviorSubject<bool>(false);
var fixture = new ReactiveCommandHolder();
var source = new Subject<int>();
source.InvokeCommand(fixture, x => x.TheCommand);
fixture.TheCommand = ReactiveCommand.Create<int>(_ => executed = true, canExecute);
source.OnNext(0);
Assert.False(executed);
canExecute.OnNext(true);
source.OnNext(0);
Assert.True(executed);
}
示例4: InvokeCommandAgainstICommandInTargetPassesTheSpecifiedValueToCanExecuteAndExecute
public void InvokeCommandAgainstICommandInTargetPassesTheSpecifiedValueToCanExecuteAndExecute()
{
var fixture = new ICommandHolder();
var source = new Subject<int>();
source.InvokeCommand(fixture, x => x.TheCommand);
var command = new FakeCommand();
fixture.TheCommand = command;
source.OnNext(42);
Assert.Equal(42, command.CanExecuteParameter);
Assert.Equal(42, command.ExecuteParameter);
}
示例5: InvokeCommandAgainstReactiveCommandInTargetInvokesTheCommand
public void InvokeCommandAgainstReactiveCommandInTargetInvokesTheCommand()
{
var executionCount = 0;
var fixture = new ReactiveCommandHolder();
var source = new Subject<int>();
source.InvokeCommand(fixture, x => x.TheCommand);
fixture.TheCommand = ReactiveCommand.Create<int>(_ => { ++executionCount; });
source.OnNext(0);
Assert.Equal(1, executionCount);
source.OnNext(0);
Assert.Equal(2, executionCount);
}
示例6: InvokeCommandAgainstICommandInTargetInvokesTheCommand
public void InvokeCommandAgainstICommandInTargetInvokesTheCommand()
{
var executionCount = 0;
var fixture = new ICommandHolder();
var source = new Subject<Unit>();
source.InvokeCommand(fixture, x => x.TheCommand);
fixture.TheCommand = ReactiveCommand.Create(() => ++executionCount);
source.OnNext(Unit.Default);
Assert.Equal(1, executionCount);
source.OnNext(Unit.Default);
Assert.Equal(2, executionCount);
}
示例7: InvokeCommandAgainstICommandRespectsCanExecuteWindow
public void InvokeCommandAgainstICommandRespectsCanExecuteWindow()
{
var executed = false;
var canExecute = new BehaviorSubject<bool>(false);
var fixture = (ICommand)ReactiveCommand.Create(() => executed = true, canExecute);
var source = new Subject<Unit>();
source.InvokeCommand(fixture);
source.OnNext(Unit.Default);
Assert.False(executed);
// The execution window re-opens, but the above execution request should not be instigated because
// it occurred when the window was closed. Execution requests do not queue up when the window is closed.
canExecute.OnNext(true);
Assert.False(executed);
}
示例8: InvokeCommandAgainstICommandRespectsCanExecute
public void InvokeCommandAgainstICommandRespectsCanExecute()
{
var executed = false;
var canExecute = new BehaviorSubject<bool>(false);
var fixture = (ICommand)ReactiveCommand.Create(() => executed = true, canExecute);
var source = new Subject<Unit>();
source.InvokeCommand(fixture);
source.OnNext(Unit.Default);
Assert.False(executed);
canExecute.OnNext(true);
source.OnNext(Unit.Default);
Assert.True(executed);
}
示例9: InvokeCommandAgainstICommandPassesTheSpecifiedValueToCanExecuteAndExecute
public void InvokeCommandAgainstICommandPassesTheSpecifiedValueToCanExecuteAndExecute()
{
var fixture = new FakeCommand();
var source = new Subject<int>();
source.InvokeCommand(fixture);
source.OnNext(42);
Assert.Equal(42, fixture.CanExecuteParameter);
Assert.Equal(42, fixture.ExecuteParameter);
}
示例10: InvokeCommandAgainstReactiveCommandInvokesTheCommand
public void InvokeCommandAgainstReactiveCommandInvokesTheCommand()
{
var executionCount = 0;
var fixture = ReactiveCommand.Create(() => ++executionCount);
var source = new Subject<Unit>();
source.InvokeCommand(fixture);
source.OnNext(Unit.Default);
Assert.Equal(1, executionCount);
source.OnNext(Unit.Default);
Assert.Equal(2, executionCount);
}