Пример #1
0
    public static void Main(string[] args)
    {
        IReceiver receiver = new Receiver();

        ICommand commandA = new CommandA(receiver);
        ICommand commandB = new CommandB(receiver);

        commandA.Execute();
        commandB.Execute();
    }
        public PageRendererTestPageViewModel(INavigationService navigationService, CoreModel coreModel) : base(navigationService)
        {
            KeyHistory     = coreModel.ObserveProperty(x => x.KeyHistory).ToReadOnlyReactiveProperty();
            KeyDownCommand = new ReactiveCommand <string>().WithSubscribe(x => coreModel.SetKeyHistory(x));

            MethodHistory = coreModel.ObserveProperty(x => x.MethodHistory).ToReadOnlyReactiveProperty();
            CommandA.Subscribe(_ => coreModel.MethodA());
            CommandB.Subscribe(_ => coreModel.MethodB());
            CommandC.Subscribe(_ => coreModel.MethodC());
        }
Пример #3
0
        public async Task TestValidateCommandWithoutValidator()
        {
            var commandB = new CommandB();
            var result = await Validate.Command(commandB)
                .ThenFindValidator(_validatorRepo.FindValidatorFor)
                .ThenCreateValidator(t => Default.CreateHandler(t) as IValidator)
                .ThenValidate();

            result.ShouldBe(commandB);
        }
Пример #4
0
        public void Start()
        {
            var commandB = new CommandB
            {
                Id   = Guid.NewGuid(),
                DoB  = DateTime.UtcNow,
                Name = "Trevor"
            };

            _bus.Send("HostB", commandB);
        }
Пример #5
0
            public override bool AreSame(Command obj)
            {
                CommandB other = obj as CommandB;

                if (other == null)
                {
                    return(false);
                }

                return(other.Name == this.Name);
            }
Пример #6
0
    private void Start()
    {
        CommandManager cm = new CommandManager();
        //建立一个Command重复使用
        Command c = null;

        c = new CommandA(new ReciverA(), "命令A1");
        cm.AddCommand(c);
        c = new CommandA(new ReciverA(), "命令A2");
        cm.AddCommand(c);
        c = new CommandB(new ReciverB(), "命令B1");
        cm.AddCommand(c);

        //执行
        cm.ExecuateCommand();
    }
Пример #7
0
            public override async Task Run()
            {
                var commandA = new CommandA();
                var commandB = new CommandB();

                var resulta1 = await _exampleCommandDispatcher.Dispatch <CommandA, Result1>(commandA);

                var resulta2 = await _exampleCommandDispatcher.Dispatch <CommandA, Result2>(commandA);

                var resultb1 = await _exampleCommandDispatcher.Dispatch <CommandB, Result1>(commandB);

                var resultb2 = await _exampleCommandDispatcher.Dispatch <CommandB, Result2>(commandB);

                Console.WriteLine(resulta1.GetType());
                Console.WriteLine(resulta2.GetType());
                Console.WriteLine(resultb1.GetType());
                Console.WriteLine(resultb2.GetType());

                Console.ReadLine();
            }
Пример #8
0
            public override Command DeserializeCommand(BinaryReader str)
            {
                if (str == null)
                {
                    throw new ArgumentNullException("str");
                }

                CommandB c      = new CommandB();
                bool     isNull = str.ReadBoolean();

                if (isNull)
                {
                    c.Name = null;
                }
                else
                {
                    c.Name = str.ReadString();
                }

                return(c);
            }
Пример #9
0
 private void RefreshCommands()
 {
     CommandA.RaiseCanExecuteChanged();
     CommandB.RaiseCanExecuteChanged();
     CommandC.RaiseCanExecuteChanged();
 }
Пример #10
0
 public void Execute(CommandB command)
 {
     _commandHandlerB.Execute(command);
 }