Esempio n. 1
0
        public MainWindow(ILoggingService loggingService, IDirtySerializableCacheService serializableService)
        {
            _loggingService      = loggingService;
            _serializableService = serializableService;

            InitializeComponent();
        }
Esempio n. 2
0
        public MainWindowViewModel(ICoinRepository coinRepository,
                                   IUnitOfWorkFactory unitOfWorkFactory,
                                   ICoinModelFactory coinModelFactory,
                                   IDirtySerializableCacheService serializableCacheService)
        {
            _coinModelFactory         = coinModelFactory;
            _serializableCacheService = serializableCacheService;

            RemoveCoinCommand          = new RelayCommand <WindowCommandContext>(RemoveCoin, CanRemoveCoin);
            ShowEditCoinControlCommand = new RelayCommand(ShowEditCoinControl, CanShowEditCoinControl);
            ShowAddCoinControlCommand  = new RelayCommand(ShowAddCoinControl);
            SaveAllCommand             = new RelayCommand <WindowCommandContext>(SaveAll, CanSaveAll);
            AddNewCoinCommand          = new RelayCommand <WindowCommandContext>(AddNewCoin);
            ToggleGroupingPanelCommand = new RelayCommand(ToggleGroupingPanel);

            _serializableCacheService.CacheChanged += CacheChangedHandler;

            using (unitOfWorkFactory.Create())
            {
                Coins.AddRange(coinRepository.GetAll().Select(x => _coinModelFactory.Create(x)));
            }

            CoinsCollectionView = CollectionViewSource.GetDefaultView(Coins);
            CoinsCollectionView.CurrentChanged += CoinsCollectionChangedHandler;
        }
Esempio n. 3
0
        public CoinModelFactory(IDirtySerializableCacheService serializableCacheService,
                                IDialogService dialogService,
                                IImageReaderService imageReaderService,
                                IImageCacheService imageCacheService)
        {
            if (serializableCacheService == null)
            {
                throw new ArgumentNullException(nameof(serializableCacheService));
            }
            if (dialogService == null)
            {
                throw new ArgumentNullException(nameof(dialogService));
            }
            if (imageReaderService == null)
            {
                throw new ArgumentNullException(nameof(imageReaderService));
            }
            if (imageCacheService == null)
            {
                throw new ArgumentNullException(nameof(imageCacheService));
            }

            _serializableCacheService = serializableCacheService;
            _dialogService            = dialogService;
            _imageReaderService       = imageReaderService;
            _imageCacheService        = imageCacheService;
        }
Esempio n. 4
0
        public CoinModel(Coin coin,
                         IDirtySerializableCacheService serializableCacheService,
                         IDialogService dialogService,
                         IImageReaderService imageReaderService,
                         IImageCacheService imageCacheService)
            : base(serializableCacheService)
        {
            _dialogService      = dialogService;
            _imageReaderService = imageReaderService;
            _imageCacheService  = imageCacheService;

            _coin = coin;

            Images        = new ObservableCollection <Image>(coin.Images ?? new List <Image>());
            SelectedImage = Images.FirstOrDefault();

            AddCoinImageCommand    = new RelayCommand <WindowCommandContext>(AddCoinImage);
            RemoveCoinImageCommand = new RelayCommand <WindowCommandContext>(RemoveCoinImage);

            Validator.AddRule(() => Title, () => RuleResult.Assert(!string.IsNullOrWhiteSpace(Title), Resources.ErrorBlankField));
            Validator.AddRule(() => Country, () => RuleResult.Assert(Country != null, Resources.ErrorBlankField));
            Validator.AddRule(() => Currency, () => RuleResult.Assert(Currency != null, Resources.ErrorBlankField));

            Validator.ValidateAll();
        }
Esempio n. 5
0
        protected DirtyObservableObject(IDirtySerializableCacheService serializableCacheService)
        {
            if (serializableCacheService == null)
            {
                throw new ArgumentNullException(nameof(serializableCacheService));
            }

            SerializableCacheService = serializableCacheService;
        }
Esempio n. 6
0
 protected ValidatatbleObservableObject(IDirtySerializableCacheService serializableCacheService)
     : base(serializableCacheService)
 {
     Validator            = new ValidationHelper();
     DataErrorInfoAdapter = new DataErrorInfoAdapter(Validator);
 }