// private Views.PackageManager view; public void Initialize(Views.PackageManager view) { var provider = NuGetPackageManager.Instance.DefaultSourceRepositoryProvider.PackageSourceProvider; var sources = provider.LoadPackageSources(); view.PackageSources = new System.Collections.ObjectModel.ObservableCollection <PackageSourceWrapper>(); view.PackageSources.Add(new PackageSourceWrapper()); foreach (var source in sources) { view.PackageSources.Add(new PackageSourceWrapper(source)); } if (view.SelectedPackageSource == null) { //view.SelectedPackageSource = sources.FirstOrDefault(); Task.Run(async() => { await Task.Delay(100); GenericTools.RunUI(() => { view.treePackageSources.SelectItem(sources.FirstOrDefault()); view.FilterText = ""; view.IsBusy = false; }); }); } }
// private Views.PackageManager view; public void Initialize(Views.PackageManager view) { var provider = NuGetPackageManager.Instance.DefaultSourceRepositoryProvider.PackageSourceProvider; var sources = provider.LoadPackageSources(); view.PackageSources = new System.Collections.ObjectModel.ObservableCollection <PackageSourceWrapper>(); view.PackageSources.Add(new PackageSourceWrapper()); foreach (var source in sources) { view.PackageSources.Add(new PackageSourceWrapper(source)); } if (view.SelectedPackageSource == null) { //view.SelectedPackageSource = sources.FirstOrDefault(); view.treePackageSources.SelectItem(sources.FirstOrDefault()); view.FilterText = ""; } }
public async Task Search(Project project, Views.PackageManager view, bool includePrerelease, string searchString) { if (source == null) { if (view.PackageSourceItems == null) { view.PackageSourceItems = new System.Collections.ObjectModel.ObservableCollection <PackageSearchItem>(); } if (_cacheinstalled == null) { _cacheinstalled = new List <PackageSearchItem>(); if (project.dependencies != null) { foreach (var jp in project.dependencies) { var ver_range = NuGet.Versioning.VersionRange.Parse(jp.Value); if (ver_range.IsMinInclusive) { var target_ver = NuGet.Versioning.NuGetVersion.Parse(ver_range.MinVersion.ToString()); var _temp = await NuGetPackageManager.Instance.GetLocal(project, new NuGet.Packaging.Core.PackageIdentity(jp.Key, target_ver)); foreach (var item in _temp) { if (_cacheinstalled.Where(x => x.Id == item.Id).FirstOrDefault() == null) { _cacheinstalled.Add(item); } } } } } } view.PackageSourceItems.Clear(); foreach (var item in _cacheinstalled) { if (!string.IsNullOrEmpty(searchString) && item.Id.Contains(searchString)) { view.PackageSourceItems.Add(item); } else { view.PackageSourceItems.Add(item); } } return; } if (!string.IsNullOrEmpty(_currentsearchString)) { _currentsearchString = searchString; return; } _currentsearchString = searchString; _ = Task.Run(async() => { Log.Debug("Searching for '" + searchString + "'"); var result = await NuGetPackageManager.Instance.Search(project, source, includePrerelease, searchString); Log.Debug("Update list of packages based on '" + searchString + "'"); GenericTools.RunUI(() => { }); if (!string.IsNullOrEmpty(_currentsearchString) && _currentsearchString != searchString) { var _searchString = _currentsearchString; _currentsearchString = null; _ = Search(project, view, includePrerelease, _searchString); } else { _currentsearchString = null; GenericTools.RunUI(() => { if (view.PackageSourceItems == null) { view.PackageSourceItems = new System.Collections.ObjectModel.ObservableCollection <PackageSearchItem>(); } view.PackageSourceItems.Clear(); foreach (var item in result) { var _item = new PackageSearchItem(project, item); view.PackageSourceItems.Add(_item); } view.IsBusy = false; }); } }); }