main
 1using gorilla.infrastructure.container;
 2
 3namespace solidware.financials.windows.ui.presenters
 4{
 5    public class WPFCommandBuilder : UICommandBuilder
 6    {
 7        DependencyRegistry container;
 8
 9        public WPFCommandBuilder(DependencyRegistry container)
10        {
11            this.container = container;
12        }
13
14        public ObservableCommand build<Command>(Presenter presenter) where Command : UICommand
15        {
16            var command = container.get_a<Command>();
17            return new SimpleCommand(() =>
18            {
19                command.run(presenter);
20            });
21        }
22
23        public ObservableCommand build<Command, Specification>(Presenter presenter) where Command : UICommand where Specification : UISpecification
24        {
25            var command = container.get_a<Command>();
26            var specification = container.get_a<Specification>();
27            return new SimpleCommand(() =>
28            {
29                command.run(presenter);
30            }, () => specification.is_satisfied_by(presenter) );
31        }
32    }
33}