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;
            }
        }
        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));
 }