master
 1using System;
 2
 3namespace MVPtoMVVM.mvvm.viewmodels
 4{
 5    public class SimpleCommand : IObservableCommand
 6    {
 7        private readonly Action command;
 8        private readonly Func<bool> predicate;
 9        public event EventHandler CanExecuteChanged = (o, e) => { };
10
11        public SimpleCommand(Action command): this(command, () => true) {}
12
13        public SimpleCommand(Action command, Func<bool> predicate)
14        {
15            this.command = command;
16            this.predicate = predicate;
17        }
18
19        public void Execute(object parameter)
20        {
21            command();
22        }
23
24        public bool CanExecute(object parameter)
25        {
26            return predicate();
27        }
28
29        public void Changed()
30        {
31            CanExecuteChanged(this, EventArgs.Empty);
32        }
33
34    }
35}