private void InitializePackageSources(PackageSourcesViewModel packageSourcesViewModel) { // Set the loading message and set Loading to true Loading = true; LoadingMessage = this.Descriptor.LoadingMessage; // Setup the PackageSourceViewModel this.PackageSourcesViewModel = packageSourcesViewModel; this.SelectedFeedSourceItem = this.PackageSourcesViewModel.ActiveFeedSource; }
/// <summary> /// Shows a custom NuGet-style gallery. /// </summary> /// <param name="galleryId">A gallery descriptor for the gallery</param> /// <param name="installRoot">Root path for installing packages.</param> /// <returns>Task that shows the gallery.</returns> public Task <bool?> ShowGallery( INuGetGalleryDescriptor descriptor, string installRoot) { var feedSource = new FeedSource(descriptor.FeedUri, descriptor.FeedName) { IsBuiltIn = true, FilterTag = descriptor.FilterTag, }; var preferences = this.Host.GetExtensionSpecificPreferences(descriptor.PreferencesStore); IFeedSourceStore feedSourceStore; // we special case the NuGet gallery to use the system-wide NuGet store feedSourceStore = new NuGetFeedSourceStore(preferences); // Customize the custom gallery var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var viewModel = new NuGetViewModel( descriptor, this.Host, packageSourcesViewModel, (sourceUrl, siteRoot) => new NuGetPackageManager( sourceUrl, siteRoot, this.Host), installRoot, GetCurrentTaskScheduler()); viewModel.ShouldShowPrereleaseFilter = true; return(Task.Factory.StartNew <bool?>(() => { var view = new NuGetView(descriptor.DialogTitle); // show the gallery view view.DataContext = viewModel; return this.Host.ShowDialog(null, view); }, CancellationToken.None, TaskCreationOptions.None, GetCurrentTaskScheduler())); }
/// <summary> /// Shows a custom NuGet-style gallery. /// </summary> /// <param name="galleryId">A gallery descriptor for the gallery</param> /// <param name="installRoot">Root path for installing packages.</param> /// <returns>Task that shows the gallery.</returns> public Task<bool?> ShowGallery( INuGetGalleryDescriptor descriptor, string installRoot) { var feedSource = new FeedSource(descriptor.FeedUri, descriptor.FeedName) { IsBuiltIn = true, FilterTag = descriptor.FilterTag, }; var preferences = this.Host.GetExtensionSpecificPreferences(descriptor.PreferencesStore); IFeedSourceStore feedSourceStore; // we special case the NuGet gallery to use the system-wide NuGet store feedSourceStore = new NuGetFeedSourceStore(preferences); // Customize the custom gallery var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var viewModel = new NuGetViewModel( descriptor, this.Host, packageSourcesViewModel, (sourceUrl, siteRoot) => new NuGetPackageManager( sourceUrl, siteRoot, this.Host), installRoot, GetCurrentTaskScheduler()); viewModel.ShouldShowPrereleaseFilter = true; return Task.Factory.StartNew<bool?>(() => { var view = new NuGetView(descriptor.DialogTitle); // show the gallery view view.DataContext = viewModel; return this.Host.ShowDialog(null, view); }, CancellationToken.None, TaskCreationOptions.None, GetCurrentTaskScheduler()); }
/// <summary> /// Initializes a new instance of the <see cref="T:NuGetViewModel"/> class. /// </summary> public NuGetViewModel( INuGetGalleryDescriptor descriptor, IWebMatrixHost host, PackageSourcesViewModel packageSourcesViewModel, Func <Uri, string, INuGetPackageManager> packageManagerCreator, string destination, TaskScheduler scheduler) { this.Descriptor = descriptor; this.Host = host; this.Scheduler = scheduler; _packageManagerCreator = packageManagerCreator; _destination = destination; _preferences = this.Host.GetExtensionSpecificPreferences(this.Descriptor.PreferencesStore); _selectedPrereleaseFilter = LoadPrereleaseFilter(); _includePrerelease = (_selectedPrereleaseFilter == Resources.Prerelease_Filter_IncludePrerelease); PackagesToDisplayForUpdateAll = new List <PackageViewModel>(); this.ShowDetailsPageCommand = new RelayCommand(this.ShowDetailsPage, this.CanShowDetailsPage); this.ShowLicensePageCommand = new RelayCommand(this.ShowLicensePage, this.CanShowLicensePage); this.ShowUninstallPageCommand = new RelayCommand(this.ShowUninstallPage, this.CanShowUninstallPage); this.ShowListCommand = new RelayCommand(this.ShowList, this.CanShowList); this.InstallCommand = new RelayCommand(this.Install, this.CanInstall); this.UpdateCommand = new RelayCommand(this.Update, this.CanUpdate); this.UninstallCommand = new RelayCommand(this.Uninstall, this.CanUninstall); this.UpdateAllCommand = new RelayCommand(this.UpdateAll, this.CanUpdateAll); this.ShowLicensePageForAllCommand = new RelayCommand(this.ShowLicensePageForAll, this.CanShowLicensePageForAll); this.DisableCommand = new RelayCommand(this.Disable, this.CanDisable); this.EnableCommand = new RelayCommand(this.Enable, this.CanEnable); this.DefaultActionCommand = new RelayCommand(this.DefaultAction, this.CanDefaultAction); // Initialize the Package Sources InitializePackageSources(packageSourcesViewModel); }
/// <summary> /// Initializes a new instance of the <see cref="T:NuGetViewModel"/> class. /// </summary> public NuGetViewModel( INuGetGalleryDescriptor descriptor, IWebMatrixHost host, PackageSourcesViewModel packageSourcesViewModel, Func<Uri, string, INuGetPackageManager> packageManagerCreator, string destination, TaskScheduler scheduler) { this.Descriptor = descriptor; this.Host = host; this.Scheduler = scheduler; _packageManagerCreator = packageManagerCreator; _destination = destination; _preferences = this.Host.GetExtensionSpecificPreferences(this.Descriptor.PreferencesStore); _selectedPrereleaseFilter = LoadPrereleaseFilter(); _includePrerelease = (_selectedPrereleaseFilter == Resources.Prerelease_Filter_IncludePrerelease); PackagesToDisplayForUpdateAll = new List<PackageViewModel>(); this.ShowDetailsPageCommand = new RelayCommand(this.ShowDetailsPage, this.CanShowDetailsPage); this.ShowLicensePageCommand = new RelayCommand(this.ShowLicensePage, this.CanShowLicensePage); this.ShowUninstallPageCommand = new RelayCommand(this.ShowUninstallPage, this.CanShowUninstallPage); this.ShowListCommand = new RelayCommand(this.ShowList, this.CanShowList); this.InstallCommand = new RelayCommand(this.Install, this.CanInstall); this.UpdateCommand = new RelayCommand(this.Update, this.CanUpdate); this.UninstallCommand = new RelayCommand(this.Uninstall, this.CanUninstall); this.UpdateAllCommand = new RelayCommand(this.UpdateAll, this.CanUpdateAll); this.ShowLicensePageForAllCommand = new RelayCommand(this.ShowLicensePageForAll, this.CanShowLicensePageForAll); this.DisableCommand = new RelayCommand(this.Disable, this.CanDisable); this.EnableCommand = new RelayCommand(this.Enable, this.CanEnable); this.DefaultActionCommand = new RelayCommand(this.DefaultAction, this.CanDefaultAction); // Initialize the Package Sources InitializePackageSources(packageSourcesViewModel); }