コード例 #1
0
 private async Task ExecuteEditor(ReactiveEditCommand commandSpec)
 {
     var editor = commandSpec.CreateEditor();
     try
     {
         Editing = Some(commandSpec.Editable);
         await editor.Edit();
     }
     finally
     {
         Editing = None;
     }
 }
コード例 #2
0
        private async Task ExecuteEditor(ReactiveEditCommand commandSpec)
        {
            var editor = commandSpec.CreateEditor();

            try
            {
                Editing = Some(commandSpec.Editable);
                await editor.Edit();
            }
            finally
            {
                Editing = None;
            }
        }
コード例 #3
0
        public IReactiveCommand Register(ReactiveEditCommand commandSpec, IScheduler scheduler)
        {
            var canExecute = this.WhenAnyValue(p => p.Editing)
                .CombineLatest(commandSpec.CanExecute, (a, b) => a.IsNone && b)
                .ObserveOn(scheduler);

            var command = ReactiveCommand.Create(canExecute);
            command
                .ObserveOn(commandSpec.EditorScheduler)
                .Subscribe(async _ =>
                {
                    try
                    {
                        await ExecuteEditor(commandSpec);
                    }
                    catch (Exception e)
                    {
                        e.Show();
                    }
                });
            return command;
        }
コード例 #4
0
        public IReactiveCommand Register(ReactiveEditCommand commandSpec, IScheduler scheduler)
        {
            var canExecute = this.WhenAnyValue(p => p.Editing)
                             .CombineLatest(commandSpec.CanExecute, (a, b) => a.IsNone && b)
                             .ObserveOn(scheduler);

            var command = ReactiveCommand.Create(canExecute);

            command
            .ObserveOn(commandSpec.EditorScheduler)
            .Subscribe(async _ =>
            {
                try
                {
                    await ExecuteEditor(commandSpec);
                }
                catch (Exception e)
                {
                    e.Show();
                }
            });
            return(command);
        }
コード例 #5
0
 public static IReactiveCommand RegisterWith(this ReactiveEditCommand command, ISerialCommandController serialCommandController, IScheduler schedular)
 {
     return(serialCommandController.Register(command, schedular));
 }