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


C# DelegateCommand.Execute方法代码示例

本文整理汇总了C#中DelegateCommand.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# DelegateCommand.Execute方法的具体用法?C# DelegateCommand.Execute怎么用?C# DelegateCommand.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DelegateCommand的用法示例。


在下文中一共展示了DelegateCommand.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WhenNoCanExecuteSpecified_ThenExecutesAlways

        public void WhenNoCanExecuteSpecified_ThenExecutesAlways()
        {
            var executed = 0;
            var command = new DelegateCommand(() => executed++);

            command.Execute(new object());
            command.Execute(new object());

            Assert.Equal(2, executed);
        }
开发者ID:netfx,项目名称:extensions,代码行数:10,代码来源:DelegateCommandSpec.cs

示例2: Main

        static void Main(string[] args)
        {
            Receiver receiver = new Receiver();
            Command command = new ConcreteCommand(receiver);
            var results = command.Execute().Results;
            Console.WriteLine(results);

            bool condition = false;
            DelegateCommand delegateCommand = new DelegateCommand(() => Console.WriteLine("Hello World!"), () => condition);
            delegateCommand.Execute();
            condition = true;
            delegateCommand.Execute();
        }
开发者ID:kodefuguru,项目名称:Presentations,代码行数:13,代码来源:Program.cs

示例3: ExecuteTest3

        public void ExecuteTest3()
        {
            var executed = false;
            var canExecute = true;
            var command = new DelegateCommand(() => executed = true, () => canExecute);

            Assert.IsTrue(command.CanExecute(null));
            command.Execute(null);
            Assert.IsTrue(executed);

            executed = false;
            canExecute = false;
            Assert.IsFalse(command.CanExecute(null));
            command.Execute(null);
            Assert.IsFalse(executed);
        }
开发者ID:jbe2277,项目名称:waf,代码行数:16,代码来源:DelegateCommandTest.cs

示例4: Execute_should_run_action_with_progress_monitor

 public void Execute_should_run_action_with_progress_monitor()
 {
     var monitor = MockRepository.GenerateStub<IProgressMonitor>();
     var command = new DelegateCommand(pm => Assert.AreEqual(monitor, pm));
     
     command.Execute(monitor);
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:DelegateCommandTest.cs

示例5: ContactEditorViewModel

        public ContactEditorViewModel(ICommandInvoker commandInvoker, IQueryInvoker queryInvoker)
        {
            this.queryInvoker = queryInvoker;
            Contacts = queryInvoker.Query<AllContactsQueryResult>().Contacts;

            SaveCommand = new DelegateCommand(() =>
                {
                    if (CurrentContact.Command is UpdateContactCommand)
                    {
                        commandInvoker.Execute<UpdateContactCommand, UpdateContactQueryResult>((UpdateContactCommand) CurrentContact.Command);
                    }
                    else
                    {
                        commandInvoker.Execute<CreateContactCommand, CreateContactQueryResult>(CurrentContact.Command);
                    }

                    Contacts = queryInvoker.Query<AllContactsQueryResult>().Contacts;
                });

            NewCommand = new DelegateCommand(() =>
                {
                    var modifyContactQueryResult = queryInvoker.Query<CreateContactQueryResult>();
                    CurrentContact = new CreateContactViewModel(modifyContactQueryResult, new ValidationService());
                });
            NewCommand.Execute(null);
        }
开发者ID:ChrisPrentice,项目名称:ArchSpike,代码行数:26,代码来源:ContactEditorViewModel.cs

示例6: ExecuteNoPredicateWithNull

 public void ExecuteNoPredicateWithNull()
 {
     bool called = false;
     DelegateCommand cmd = new DelegateCommand((o) => called = true);
     Assert.IsTrue(cmd.CanExecute(null), "Command should always be able to execute when no predicate is supplied.");
     cmd.Execute(null);
     Assert.IsTrue(called, "Command did not run supplied Action.");
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:8,代码来源:DelegateCommandTests.cs

示例7: ExecuteTest

        public void ExecuteTest()
        {
            bool executed = false;
            DelegateCommand command = new DelegateCommand(() => executed = true);

            command.Execute(null);
            Assert.IsTrue(executed);
        }
开发者ID:keremkusmezer,项目名称:baldursgatepartygold,代码行数:8,代码来源:DelegateCommandTest.cs

示例8: ExecuteTest_CanExecute_True

        public void ExecuteTest_CanExecute_True()
        {
            bool executed = false;
            bool canExecute = true;
            DelegateCommand command = new DelegateCommand(() => executed = true, () => canExecute);

            command.Execute();
            Assert.IsTrue(executed);
        }
开发者ID:BigEgg,项目名称:Core,代码行数:9,代码来源:DelegateCommandTest.cs

示例9: Execute_should_run_action

        public void Execute_should_run_action()
        {
            bool flag = false;
            var command = new DelegateCommand(pm => flag = true);

            command.Execute(MockRepository.GenerateStub<IProgressMonitor>());

            Assert.IsTrue(flag);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:9,代码来源:DelegateCommandTest.cs

示例10: WhenExecuteParameterIsNull_ThenExecutes

        public void WhenExecuteParameterIsNull_ThenExecutes()
        {
            var executed = false;
            var command = new DelegateCommand(() => executed = true, () => true);

            command.Execute(null);

            Assert.True(executed);
        }
开发者ID:netfx,项目名称:extensions,代码行数:9,代码来源:DelegateCommandSpec.cs

示例11: Execute_WithoutCanExecute__DelegateCalled

        public void Execute_WithoutCanExecute__DelegateCalled()
        {
            var called = false;
            var subject = new DelegateCommand(() => { called = true; });

            subject.Execute();

            Assert.IsTrue(called);
        }
开发者ID:JackTheRipper42,项目名称:Binding,代码行数:9,代码来源:DelegateCommandTest.cs

示例12: WhenCanExecuteReturnsFalse_ThenDoesNotExecute

        public void WhenCanExecuteReturnsFalse_ThenDoesNotExecute()
        {
            var executed = false;
            var command = new DelegateCommand(() => executed = true, () => false);

            command.Execute(new object());

            Assert.False(executed);
        }
开发者ID:netfx,项目名称:extensions,代码行数:9,代码来源:DelegateCommandSpec.cs

示例13: WhenCanExecuteReturnsTrue_ThenExecutes

        public void WhenCanExecuteReturnsTrue_ThenExecutes()
        {
            var executed = false;
            var command = new DelegateCommand(() => executed = true, () => true);

            command.Execute(new object());

            Assert.True(executed);
        }
开发者ID:netfx,项目名称:extensions,代码行数:9,代码来源:DelegateCommandSpec.cs

示例14: ExecuteTest4

        public void ExecuteTest4()
        {
            bool executed = false;
            bool canExecute = false;
            DelegateCommand command = new DelegateCommand(() => executed = true, () => canExecute);

            AssertHelper.ExpectedException<InvalidOperationException>(() => command.Execute(null));
            Assert.IsFalse(executed);
        }
开发者ID:keremkusmezer,项目名称:baldursgatepartygold,代码行数:9,代码来源:DelegateCommandTest.cs

示例15: ExecuteCallsPassedInExecuteDelegate

        public void ExecuteCallsPassedInExecuteDelegate()
        {
            var handlers = new DelegateHandlers();
            var command = new DelegateCommand<object>(handlers.Execute, null);
            object parameter = new object();

            command.Execute(parameter);

            Assert.AreSame(parameter, handlers.ExecuteParameter);
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:10,代码来源:DelegateCommandFixture.cs


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