Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            // Use this as construction root for simplicity.
            // In real world app there should be good framework for this and this should be done
            // outside of main window for reason that then mainwindow is interchangeable too if required.
            var dataSource = new InMemoryRepository();

            // Dummy data for testing...
            dataSource.Add(new CarImage {Color="Black", RegisterPlate = "ABC-123", Speed = 140});

            var messenger = new MessageAggregator();
            var reportViewModel = new ReportViewModel(dataSource, messenger);
            var colorFilter = new ColorFilterViewModel();
            var filterViewModel = new FiltersViewModel(new List<IFilter> {colorFilter}, messenger);

            // Just for testing, apply dummy filter so that data is shown.
            messenger.Publish(new Messages.FiltersAppliedMessage());

            DataContext = new
            {
                Report = reportViewModel,
                Filters = filterViewModel
            };
        }
        public void Init()
        {
            _repository = TestDataTemplates.CreateRepository();
            _messenger = new MessageAggregator();
            _reportsViewModel = new ReportViewModel(_repository, _messenger);

            _colorFilter = new ColorFilterViewModel();
            _registerFilter = new RegisterPlateFilterViewModel();

            var filters = new List<IFilter> {_colorFilter, _registerFilter};

            _filtersViewModel = new FiltersViewModel(filters, _messenger);
        }
 public void Init()
 {
     _repository = new InMemoryRepository();
     _messagenger = new MessageAggregator();
     _viewModel = new ReportViewModel(_repository, _messagenger);
 }