コード例 #1
0
        public PackageChooserViewModel(
            MruPackageSourceManager packageSourceManager,
            ICredentialManager credentialManager,
            bool showPrereleasePackages,
            bool autoLoadPackages,
            string fixedPackageSource)
        {
            if (packageSourceManager == null)
            {
                throw new ArgumentNullException("packageSourceManager");
            }
            if (credentialManager == null)
            {
                throw new ArgumentNullException("credentialManager");
            }

            _showPrereleasePackages = showPrereleasePackages;
            _fixedPackageSource     = fixedPackageSource;
            _autoLoadPackages       = autoLoadPackages;
            Packages                   = new ObservableCollection <PackageInfoViewModel>();
            SortCommand                = new RelayCommand <string>(Sort, CanSort);
            SearchCommand              = new RelayCommand <string>(Search, CanSearch);
            ClearSearchCommand         = new RelayCommand(ClearSearch, CanClearSearch);
            NavigationCommand          = new RelayCommand <string>(NavigationCommandExecute, NavigationCommandCanExecute);
            LoadedCommand              = new RelayCommand(async() => await Sort("VersionDownloadCount", ListSortDirection.Descending));
            ChangePackageSourceCommand = new RelayCommand <string>(ChangePackageSource);
            CancelCommand              = new RelayCommand(CancelCommandExecute, CanCancelCommandExecute);
            _packageSourceManager      = packageSourceManager;
            _credentialManager         = credentialManager;
        }
コード例 #2
0
        private void PublishExecute()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(Resources.NoNetworkConnection, MessageLevel.Warning);
                return;
            }

            // validate the package to see if there is any error before actually creating the package.
            var firstIssue = Validate().FirstOrDefault(p => p.Level == PackageIssueLevel.Error);

            if (firstIssue != null)
            {
                UIServices.Show(
                    Resources.PackageCreationFailed
                    + Environment.NewLine
                    + Environment.NewLine
                    + firstIssue.Description,
                    MessageLevel.Warning);
                return;
            }

            using (var mruSourceManager = new MruPackageSourceManager(
                       new PublishSourceSettings(_settingsManager)))
            {
                var publishPackageViewModel = new PublishPackageViewModel(
                    mruSourceManager,
                    _settingsManager,
                    _uiServices,
                    _credentialPublishProvider,
                    this);
                _uiServices.OpenPublishDialog(publishPackageViewModel);
            }
        }
        public void Dispose()
        {
            if (_packageSourceManager != null)
            {
                _packageSourceManager.Dispose();
                _packageSourceManager = null;
            }

            CurrentCancellationTokenSource?.Dispose();
        }
コード例 #4
0
        public PackageChooserViewModel CreatePackageChooserViewModel(string fixedPackageSource)
        {
            var packageSourceSettings = new PackageSourceSettings(SettingsManager);
            var packageSourceManager  = new MruPackageSourceManager(packageSourceSettings);
            var model = new PackageChooserViewModel(packageSourceManager,
                                                    SettingsManager.ShowPrereleasePackages,
                                                    fixedPackageSource);

            model.PropertyChanged += OnPackageChooserViewModelPropertyChanged;
            return(model);
        }
コード例 #5
0
 public PublishPackageViewModel(
     MruPackageSourceManager mruSourceManager,
     ISettingsManager settingsManager,
     PackageViewModel viewModel)
 {
     _mruSourceManager   = mruSourceManager;
     _settingsManager    = settingsManager;
     _package            = viewModel.PackageMetadata;
     _packageFilePath    = viewModel.GetCurrentPackageTempFile();
     SelectedPublishItem = _mruSourceManager.ActivePackageSource;
     PublishAsUnlisted   = _settingsManager.PublishAsUnlisted;
 }
 public PublishPackageViewModel(
     MruPackageSourceManager mruSourceManager,
     ISettingsManager settingsManager,
     IUIServices uiServices,
     CredentialPublishProvider credentialPublishProvider,
     PackageViewModel viewModel)
 {
     _mruSourceManager          = mruSourceManager;
     _settingsManager           = settingsManager;
     _uiServices                = uiServices;
     _credentialPublishProvider = credentialPublishProvider;
     _package            = viewModel.PackageMetadata;
     _packageFilePath    = viewModel.GetCurrentPackageTempFile();
     SelectedPublishItem = _mruSourceManager.ActivePackageSource;
     PublishAsUnlisted   = _settingsManager.PublishAsUnlisted;
 }
        public PackageChooserViewModel(MruPackageSourceManager packageSourceManager,
                                       bool showPrereleasePackages,
                                       string defaultPackageSourceUrl)
        {
            _showPrereleasePackages  = showPrereleasePackages;
            _defaultPackageSourceUrl = defaultPackageSourceUrl;
            Packages = new ObservableCollection <PackageInfoViewModel>();

            SearchCommand              = new RelayCommand <string>(Search, CanSearch);
            ClearSearchCommand         = new RelayCommand(ClearSearch, CanClearSearch);
            NavigationCommand          = new RelayCommand <string>(NavigationCommandExecute, NavigationCommandCanExecute);
            LoadedCommand              = new RelayCommand(async() => await LoadPackages());
            ChangePackageSourceCommand = new RelayCommand <string>(ChangePackageSource);
            CancelCommand              = new RelayCommand(CancelCommandExecute, CanCancelCommandExecute);

            _packageSourceManager = packageSourceManager ?? throw new ArgumentNullException(nameof(packageSourceManager));
        }
コード例 #8
0
        public PackageChooserViewModel(MruPackageSourceManager packageSourceManager,
                                       IUIServices uIServices,
                                       bool showPrereleasePackages,
                                       string?defaultPackageSourceUrl)
        {
            _showPrereleasePackages  = showPrereleasePackages;
            _defaultPackageSourceUrl = defaultPackageSourceUrl;
            Packages = new ObservableCollection <object>();

            SearchCommand              = new RelayCommand <string>(Search, CanSearch);
            ClearSearchCommand         = new RelayCommand(ClearSearch, CanClearSearch);
            LoadMoreCommand            = new RelayCommand(async() => await LoadMore(CancellationToken.None), CanLoadMore);
            ChangePackageSourceCommand = new RelayCommand <string>(ChangePackageSource);
            CancelCommand              = new RelayCommand(CancelCommandExecute, CanCancelCommandExecute);

            _packageSourceManager = packageSourceManager ?? throw new ArgumentNullException(nameof(packageSourceManager));
            _uIServices           = uIServices;
        }
コード例 #9
0
 public PublishPackageViewModel(
     MruPackageSourceManager mruSourceManager,
     ISettingsManager settingsManager,
     IUIServices uiServices,
     CredentialPublishProvider credentialPublishProvider,
     PackageViewModel viewModel)
 {
     if (viewModel is null)
     {
         throw new ArgumentNullException(nameof(viewModel));
     }
     _mruSourceManager          = mruSourceManager ?? throw new ArgumentNullException(nameof(mruSourceManager));
     _settingsManager           = settingsManager ?? throw new ArgumentNullException(nameof(settingsManager));
     _uiServices                = uiServices ?? throw new ArgumentNullException(nameof(uiServices));
     _credentialPublishProvider = credentialPublishProvider ?? throw new ArgumentNullException(nameof(credentialPublishProvider));
     _package            = viewModel.PackageMetadata;
     _packageFilePath    = viewModel.GetCurrentPackageTempFile();
     SelectedPublishItem = _mruSourceManager.ActivePackageSource;
     PublishAsUnlisted   = _settingsManager.PublishAsUnlisted;
 }
コード例 #10
0
        public PackageChooserViewModel(
            MruPackageSourceManager packageSourceManager,
            bool showPrereleasePackages,
            bool autoLoadPackages,
            string fixedPackageSource)
        {
            if (packageSourceManager == null)
            {
                throw new ArgumentNullException("packageSourceManager");
            }

            _showPrereleasePackages = showPrereleasePackages;
            _fixedPackageSource = fixedPackageSource;
            _autoLoadPackages = autoLoadPackages;
            Packages = new ObservableCollection<PackageInfoViewModel>();
            SortCommand = new RelayCommand<string>(Sort, CanSort);
            SearchCommand = new RelayCommand<string>(Search, CanSearch);
            ClearSearchCommand = new RelayCommand(ClearSearch, CanClearSearch);
            NavigationCommand = new RelayCommand<string>(NavigationCommandExecute, NavigationCommandCanExecute);
            LoadedCommand = new RelayCommand(async () => await Sort("VersionDownloadCount", ListSortDirection.Descending));
            ChangePackageSourceCommand = new RelayCommand<string>(ChangePackageSource);
            CancelCommand = new RelayCommand(CancelCommandExecute, CanCancelCommandExecute);
            _packageSourceManager = packageSourceManager;
        }
コード例 #11
0
        public void Dispose()
        {
            if (_packageSourceManager != null)
            {
                _packageSourceManager.Dispose();
                _packageSourceManager = null;
            }

            if (CurrentCancellationTokenSource != null)
            {
                CurrentCancellationTokenSource.Dispose();
            }
        }
コード例 #12
0
        private void PublishExecute()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(Resources.NoNetworkConnection, MessageLevel.Warning);
                return;
            }

            // validate the package to see if there is any error before actually creating the package.
            PackageIssue firstIssue = Validate().FirstOrDefault(p => p.Level == PackageIssueLevel.Error);
            if (firstIssue != null)
            {
                UIServices.Show(
                    Resources.PackageCreationFailed
                    + Environment.NewLine
                    + Environment.NewLine
                    + firstIssue.Description,
                    MessageLevel.Warning);
                return;
            }

            using (var mruSourceManager = new MruPackageSourceManager(
                new PublishSourceSettings(_settingsManager)))
            {
                var publishPackageViewModel = new PublishPackageViewModel(
                    mruSourceManager,
                    _settingsManager,
                    this);
                _uiServices.OpenPublishDialog(publishPackageViewModel);
            }
        }