当前位置: 首页>>代码示例>>C#>>正文


C# Subject.InvokeCommand方法代码示例

本文整理汇总了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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:17,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:11,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:16,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:12,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:14,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:14,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:16,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:15,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:10,代码来源:ReactiveCommandTest.cs

示例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);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:13,代码来源:ReactiveCommandTest.cs


注:本文中的Subject.InvokeCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。