public LocalSourceViewModel(
            IChocolateyService chocolateyService,
            IProgressService progressService,
            IPersistenceService persistenceService,
            IChocolateyGuiCacheService chocolateyGuiCacheService,
            IConfigService configService,
            IAllowedCommandsService allowedCommandsService,
            IEventAggregator eventAggregator,
            string displayName,
            IMapper mapper)
        {
            _chocolateyService         = chocolateyService;
            _progressService           = progressService;
            _persistenceService        = persistenceService;
            _chocolateyGuiCacheService = chocolateyGuiCacheService;
            _configService             = configService;
            _allowedCommandsService    = allowedCommandsService;

            DisplayName = displayName;

            _packages            = new List <IPackageViewModel>();
            Packages             = new ObservableCollection <IPackageViewModel>();
            PackageSource        = CollectionViewSource.GetDefaultView(Packages);
            PackageSource.Filter = FilterPackage;

            if (eventAggregator == null)
            {
                throw new ArgumentNullException(nameof(eventAggregator));
            }

            _eventAggregator = eventAggregator;
            _mapper          = mapper;
            _eventAggregator.Subscribe(this);
        }
Example #2
0
        public LocalSourceViewModel(
            IChocolateyService chocolateyService,
            IDialogService dialogService,
            IProgressService progressService,
            IPersistenceService persistenceService,
            IChocolateyGuiCacheService chocolateyGuiCacheService,
            IConfigService configService,
            IAllowedCommandsService allowedCommandsService,
            IEventAggregator eventAggregator,
            string displayName,
            IMapper mapper,
            TranslationSource translator)
            : base(translator)
        {
            _chocolateyService         = chocolateyService;
            _dialogService             = dialogService;
            _progressService           = progressService;
            _persistenceService        = persistenceService;
            _chocolateyGuiCacheService = chocolateyGuiCacheService;
            _configService             = configService;
            _allowedCommandsService    = allowedCommandsService;

            if (displayName[0] == '[' && displayName[displayName.Length - 1] == ']')
            {
                _resourceId = displayName.Trim('[', ']');
                DisplayName = translator[_resourceId];
                translator.PropertyChanged += (sender, e) =>
                {
                    DisplayName = translator[_resourceId];
                };
            }
            else
            {
                DisplayName = displayName;
            }

            _packages            = new List <IPackageViewModel>();
            Packages             = new ObservableCollection <IPackageViewModel>();
            PackageSource        = CollectionViewSource.GetDefaultView(Packages);
            PackageSource.Filter = FilterPackage;

            if (eventAggregator == null)
            {
                throw new ArgumentNullException(nameof(eventAggregator));
            }

            _eventAggregator = eventAggregator;
            _mapper          = mapper;
            _eventAggregator.Subscribe(this);
        }
Example #3
0
 public PackageViewModel(
     IChocolateyService chocolateyService,
     IEventAggregator eventAggregator,
     IMapper mapper,
     IProgressService progressService,
     IChocolateyGuiCacheService chocolateyGuiCacheService,
     IConfigService configService,
     IAllowedCommandsService allowedCommandsService)
 {
     _chocolateyService = chocolateyService;
     _eventAggregator   = eventAggregator;
     _mapper            = mapper;
     _progressService   = progressService;
     eventAggregator?.Subscribe(this);
     _chocolateyGuiCacheService = chocolateyGuiCacheService;
     _configService             = configService;
     _allowedCommandsService    = allowedCommandsService;
 }