Exemplo n.º 1
0
        public RemoteSourceViewModel(
            IChocolateyService chocolateyPackageService,
            IProgressService progressService,
            IConfigService configService,
            IEventAggregator eventAggregator,
            ChocolateySource source,
            IMapper mapper)
        {
            Source = source;
            _chocolateyPackageService = chocolateyPackageService;
            _progressService          = progressService;
            _configService            = configService;
            _eventAggregator          = eventAggregator;
            _mapper = mapper;

            Packages    = new ObservableCollection <IPackageViewModel>();
            DisplayName = source.Id;

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

            _eventAggregator.Subscribe(this);
        }
        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);
        }
Exemplo n.º 3
0
        public SettingsViewModel(
            IChocolateyService chocolateyService,
            IDialogService dialogService,
            IProgressService progressService,
            IConfigService configService,
            IEventAggregator eventAggregator,
            IChocolateyGuiCacheService chocolateyGuiCacheService,
            IFileSystem fileSystem)
        {
            _chocolateyService         = chocolateyService;
            _dialogService             = dialogService;
            _progressService           = progressService;
            _configService             = configService;
            _eventAggregator           = eventAggregator;
            _chocolateyGuiCacheService = chocolateyGuiCacheService;
            _fileSystem  = fileSystem;
            DisplayName  = Resources.SettingsViewModel_DisplayName;
            Activated   += OnActivated;
            Deactivated += OnDeactivated;

            ChocolateyGuiFeaturesView.Filter = new Predicate <object>(o => FilterChocolateyGuiFeatures(o as ChocolateyGuiFeature));
            ChocolateyGuiSettingsView.Filter = new Predicate <object>(o => FilterChocolateyGuiSettings(o as ChocolateyGuiSetting));
            ChocolateyFeaturesView.Filter    = new Predicate <object>(o => FilterChocolateyFeatures(o as ChocolateyFeature));
            ChocolateySettingsView.Filter    = new Predicate <object>(o => FilterChocolateySettings(o as ChocolateySetting));
        }
Exemplo n.º 4
0
        public About(IChocolateyService chocolateyService)
        {
            InitializeComponent();

            _chocolateyService = chocolateyService;
            _chocolateyService.OutputChanged += VersionChangedHandler;
        }
Exemplo n.º 5
0
        public ChocolateyModule(IChocolateyService chocoService) : base("/api/")
        {
            this.EnableCors();
            StaticConfiguration.DisableErrorTraces = false;
            m_chocoService = chocoService;

            Get["/chocoVersion"] = parameters =>
            {
                var chocoVersion = m_chocoService.ChocoVersion();
                return(Response.AsJson(chocoVersion != Constants.EmptySemanticVersion ? chocoVersion.ToNormalizedString() : "Can't find Chocolatey Version, is Chocolatey installed or missing from path?"));
            };


            Get["/chocoPackages"] = parameters =>
            {
                var chocoPackages = m_chocoService.InstalledPackages();
                return(Response.AsJson(chocoPackages));
            };

            Get["/failedChocoPackages"] = parameters =>
            {
                var failedPackages = m_chocoService.FailedPackages();
                return(Response.AsJson(failedPackages));
            };
        }
        public RemoteSourceViewModel(
            IChocolateyService chocolateyPackageService,
            IProgressService progressService,
            IConfigService configService,
            IEventAggregator eventAggregator,
            ChocolateySource source,
            IMapper mapper)
        {
            Source = source;
            _chocolateyPackageService = chocolateyPackageService;
            _progressService          = progressService;
            _configService            = configService;
            _eventAggregator          = eventAggregator;
            _mapper = mapper;

            ListViewMode = _configService.GetSettings().DefaultToTileViewForLocalSource ? ListViewMode.Tile : ListViewMode.Standard;

            Packages    = new ObservableCollection <IPackageViewModel>();
            DisplayName = source.Id;

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

            _eventAggregator.Subscribe(this);
        }
        public AdvancedInstallViewModel(
            IChocolateyService chocolateyService,
            IPersistenceService persistenceService,
            SemanticVersion packageVersion)
        {
            _chocolateyService  = chocolateyService;
            _persistenceService = persistenceService;

            _cts = new CancellationTokenSource();

            _packageVersion = packageVersion.ToString();
            SelectedVersion = _packageVersion;

            FetchAvailableVersions();

            AvailableChecksumTypes = new List <string> {
                "md5", "sha1", "sha256", "sha512"
            };
            InstallCommand = new RelayCommand(
                o => { Close?.Invoke(this); },
                o => string.IsNullOrEmpty(SelectedVersion) || SelectedVersion == Resources.AdvancedChocolateyDialog_LatestVersion || SemanticVersion.TryParse(SelectedVersion, out _));
            CancelCommand = new RelayCommand(
                o =>
            {
                _cts.Cancel();
                Close?.Invoke(null);
            },
                o => true);

            BrowseLogFileCommand       = new RelayCommand(BrowseLogFile);
            BrowseCacheLocationCommand = new RelayCommand(BrowseCacheLocation);

            SetDefaults();
        }
Exemplo n.º 8
0
        public SourcesViewModel(
            IChocolateyService packageService,
            IConfigService configService,
            IImageService imageService,
            IEventAggregator eventAggregator,
            IVersionService versionService,
            Func <string, LocalSourceViewModel> localSourceVmFactory,
            CreateRemove remoteSourceVmFactory)
        {
            _packageService        = packageService;
            _configService         = configService;
            _imageService          = imageService;
            _versionService        = versionService;
            _remoteSourceVmFactory = remoteSourceVmFactory;
            _localSourceVmFactory  = localSourceVmFactory;

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

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

            eventAggregator.Subscribe(this);
        }
 public ChocolateyLibDirHelper(IChocolateyService chocolateyService, IFileStorageService fileStorageService, ISettingsService settingsService)
 {
     _chocolateyService = chocolateyService;
     _fileStorageService = fileStorageService;
     _settingsService = settingsService;
     _chocolateyService.OutputChanged += VersionChangeFinished;
 }
Exemplo n.º 10
0
        public Help(IChocolateyService chocolateyService)
        {
            InitializeComponent();

            _chocolateyService = chocolateyService;
            _chocolateyService.OutputChanged += ChocolateyServiceOutPutChanged;
        }
 public ChocolateyLibDirHelper(IChocolateyService chocolateyService, IFileStorageService fileStorageService, ISettingsService settingsService)
 {
     _chocolateyService  = chocolateyService;
     _fileStorageService = fileStorageService;
     _settingsService    = settingsService;
     _chocolateyService.OutputChanged += VersionChangeFinished;
 }
Exemplo n.º 12
0
        public SourcesViewModel(
            IChocolateyService packageService,
            IEventAggregator eventAggregator,
            Func <string, LocalSourceViewModel> localSourceVmFactory,
            CreateRemove remoteSourceVmFactory)
        {
            _packageService        = packageService;
            _remoteSourceVmFactory = remoteSourceVmFactory;

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

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

            Items.Add(localSourceVmFactory(Resources.Resources_ThisPC));

#pragma warning disable 4014
            LoadSources();
#pragma warning restore 4014

            eventAggregator.Subscribe(this);
        }
 public void Setup()
 {
     _chocolateyService  = MockRepository.GenerateMock <IChocolateyService>();
     _fileStorageService = MockRepository.GenerateMock <IFileStorageService>();
     _settingsService    = MockRepository.GenerateMock <ISettingsService>();
     _settingsService.Stub(ssS => ssS.ChocolateyLibDirectory).Return("");
     _helper = new ChocolateyLibDirHelper(_chocolateyService, _fileStorageService, _settingsService);
 }
Exemplo n.º 14
0
        public PackageViewModel(IPackageService packageService, IChocolateyService chocolateyService, INavigationService navigationService)
        {
            _packageService    = packageService;
            _chocolateyService = chocolateyService;
            _navigationService = navigationService;
            PackagesChangedEventManager.AddListener(_chocolateyService, this);

            _isInstalled = new Lazy <bool>(() => _chocolateyService.IsPackageInstalled(Id, Version));
        }
Exemplo n.º 15
0
        public About(IChocolateyService chocolateyService)
        {
            InitializeComponent();

            _chocolateyService = chocolateyService;
            _chocolateyService.OutputChanged += VersionChangeFinished;

            GetChocolateyVersionAsync();
        }
Exemplo n.º 16
0
        public About(IChocolateyService chocolateyService)
        {
            InitializeComponent();

            _chocolateyService = chocolateyService;
            _chocolateyService.OutputChanged += VersionChangeFinished;

            GetChocolateyVersionAsync();
        }
Exemplo n.º 17
0
        public Help(IChocolateyService chocolateyService)
        {
            InitializeComponent();

            _chocolateyService = chocolateyService;
            _chocolateyService.OutputChanged += ChocolateyServiceOutPutChanged;

            LoadHelp();
        }
Exemplo n.º 18
0
        public LocalSourceControlViewModel(IChocolateyService chocolateyService, IProgressService progressService, Func <Type, ILogService> logFactory)
        {
            _chocolateyService = chocolateyService;
            _progressService   = progressService;
            _logService        = logFactory(typeof(LocalSourceControlViewModel));
            PackagesChangedEventManager.AddListener(_chocolateyService, this);

            Packages  = new ObservableCollection <IPackageViewModel>();
            _packages = new List <IPackageViewModel>();
        }
Exemplo n.º 19
0
 public PackageViewModel(
     IChocolateyService chocolateyService,
     IEventAggregator eventAggregator,
     IMapper mapper,
     IProgressService progressService)
 {
     _chocolateyService = chocolateyService;
     _eventAggregator   = eventAggregator;
     _mapper            = mapper;
     _progressService   = progressService;
     eventAggregator?.Subscribe(this);
 }
Exemplo n.º 20
0
 public SettingsViewModel(
     IChocolateyService packageService,
     IProgressService progressService,
     IConfigService configService,
     IEventAggregator eventAggregator)
 {
     _packageService  = packageService;
     _progressService = progressService;
     _configService   = configService;
     _eventAggregator = eventAggregator;
     DisplayName      = Resources.SettingsViewModel_DisplayName;
     Activated       += OnActivated;
     Deactivated     += OnDeactivated;
 }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        public ShellViewModel(
            IChocolateyService chocolateyPackageService,
            IVersionNumberProvider versionNumberProvider,
            IEventAggregator eventAggregator,
            SourcesViewModel sourcesViewModel)
        {
            _chocolateyPackageService = chocolateyPackageService;
            _versionNumberProvider    = versionNumberProvider;
            _eventAggregator          = eventAggregator;
            _sourcesViewModel         = sourcesViewModel;
            Sources    = new BindableCollection <SourceViewModel>();
            ActiveItem = _sourcesViewModel;

            GetSources();
        }
Exemplo n.º 23
0
        public RemoteSourceViewModel(
            IChocolateyService chocolateyPackageService,
            IDialogService dialogService,
            IProgressService progressService,
            IChocolateyGuiCacheService chocolateyGuiCacheService,
            IConfigService configService,
            IEventAggregator eventAggregator,
            ChocolateySource source,
            IMapper mapper,
            TranslationSource translator)
            : base(translator)
        {
            Source = source;
            _chocolateyPackageService  = chocolateyPackageService;
            _dialogService             = dialogService;
            _progressService           = progressService;
            _chocolateyGuiCacheService = chocolateyGuiCacheService;
            _configService             = configService;
            _eventAggregator           = eventAggregator;
            _mapper = mapper;

            Packages = new ObservableCollection <IPackageViewModel>();

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

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

            _eventAggregator.Subscribe(this);

            AddSortOptions();

            SortSelection = L(nameof(Resources.RemoteSourceViewModel_SortSelectionPopularity));
        }
Exemplo n.º 24
0
 public ShellViewModel(
     IChocolateyService chocolateyPackageService,
     IVersionNumberProvider versionNumberProvider,
     IEventAggregator eventAggregator,
     SourcesViewModel sourcesViewModel,
     IConfigService configService)
 {
     _chocolateyPackageService = chocolateyPackageService;
     _versionNumberProvider    = versionNumberProvider;
     _eventAggregator          = eventAggregator;
     _sourcesViewModel         = sourcesViewModel;
     _configService            = configService;
     Sources           = new BindableCollection <SourceViewModel>();
     ActiveItem        = _sourcesViewModel;
     GoToSourceCommand = new RelayCommand(GoToSource, CanGoToSource);
 }
Exemplo n.º 25
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;
 }
Exemplo n.º 26
0
 public SettingsViewModel(
     IChocolateyService chocolateyService,
     IProgressService progressService,
     IConfigService configService,
     IEventAggregator eventAggregator,
     IDialogCoordinator dialogCoordinator,
     IChocolateyGuiCacheService chocolateyGuiCacheService,
     IFileSystem fileSystem)
 {
     _chocolateyService         = chocolateyService;
     _progressService           = progressService;
     _configService             = configService;
     _eventAggregator           = eventAggregator;
     _dialogCoordinator         = dialogCoordinator;
     _chocolateyGuiCacheService = chocolateyGuiCacheService;
     _fileSystem  = fileSystem;
     DisplayName  = Resources.SettingsViewModel_DisplayName;
     Activated   += OnActivated;
     Deactivated += OnDeactivated;
 }
 public static async Task <PackageSearchResults> Search(string queryString, IChocolateyService chocolateyService, Func <IPackageViewModel> packageFactory, Uri source)
 {
     return(await Search(queryString, chocolateyService, packageFactory, new PackageSearchOptions(), source));
 }
 public ChocolateyLibDirHelper()
 {
     _chocolateyService = new ChocolateyService();
     _chocolateyService.OutputChanged += VersionChangeFinished;
 }
 public void Setup()
 {
     _chocolateyService = MockRepository.GenerateMock<IChocolateyService>();
     _fileStorageService = MockRepository.GenerateMock<IFileStorageService>();
     _settingsService = MockRepository.GenerateMock<ISettingsService>();
     _settingsService.Stub(ssS => ssS.ChocolateyLibDirectory).Return("");
     _helper = new ChocolateyLibDirHelper(_chocolateyService, _fileStorageService, _settingsService);
 }
Exemplo n.º 30
0
 public static void AddListener(IChocolateyService serivce, IWeakEventListener listener)
 {
     CurrentManager.ProtectedAddListener(serivce, listener);
 }
 public static IPackageViewModel GetLatest(string id, IChocolateyService chocolateyService, Func <IPackageViewModel> packageFactory, Uri source, bool includePrerelease = false)
 {
     throw new NotImplementedException();
 }
 public static async Task <bool> TestPath(Uri source, IChocolateyService chocolateyService)
 {
     return
         ((await
           chocolateyService.RunIndirectChocolateyCommand(string.Format("list -source \"{0}\"", source), false)).Count > 0);
 }