private void Install(Requirements requirements) { if (MachineWide && !WindowsUtils.IsAdministrator) { throw new NotAdminException(Resources.MustBeAdminForMachineWide); } if (MachineWide && ZeroInstallInstance.IsRunningFromPerUserDir) { throw new UnsuitableInstallBaseException(Resources.NoMachineWideIntegrationFromPerUser, MachineWide); } if (ZeroInstallInstance.IsRunningFromCache) { throw new UnsuitableInstallBaseException(Resources.NoIntegrationFromCache, MachineWide); } FeedManager.Refresh = Refresh || !DeferDownload; var selections = Solve(requirements); ApplyIntegration(requirements); ApplyVersionRestrictions(requirements, selections); if (!DeferDownload) { Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections)); } Yield(requirements); }
private Selections Solve(Requirements requirements) { var selections = Solver.Solve(requirements); if (FeedManager.ShouldRefresh || SelectionsManager.GetUncachedSelections(selections).Any()) { FeedManager.Stale = false; FeedManager.Refresh = true; selections = Solver.Solve(requirements); FeedManager.Refresh = false; } try { selections.Name = FeedCache.GetFeed(selections.InterfaceUri).Name; } #region Error handling catch (KeyNotFoundException) { // Fall back to using feed file name selections.Name = selections.InterfaceUri.ToString().GetRightPartAtLastOccurrence('/'); } #endregion return(selections); }
protected void BuildBreadcrumb(BreadcrumbModel breadCrumb, string category, string collection, string gender, string genderFilter) { breadCrumb.GenderFilter = genderFilter; breadCrumb.Gender = gender != null?CultureInfo.CurrentCulture.TextInfo.ToTitleCase(gender.ToLower()) : null; if (category != null) { switch (category.ToLower()) { case UrlBuilder.CATALOG_NEW_ARRIVALS: { breadCrumb.Category = new DropDownModel() { Name = "new arrivals", Value = category.ToLower() }; breadCrumb.IsCategoryForNewProds = true; break; } case UrlBuilder.CATALOG_TOPS_NEW: { breadCrumb.Category = new DropDownModel() { Name = "tops", Value = category.ToLower() }; breadCrumb.IsCategoryForNewProds = true; break; } default: { var obj = SelectionsManager.GetCategoryByName(this.CurrentBrand, category, genderFilter); if (obj != null) { breadCrumb.Category = new DropDownModel() { Name = obj.Name, Value = obj.Value } } ; break; } } } if (collection != null) { var obj = SelectionsManager.GetCollectionByName(this.CurrentBrand, collection, genderFilter); if (obj != null) { breadCrumb.Collection = new DropDownModel() { Name = obj.Name, Value = obj.Value } } ; } }
#pragma warning restore 8776 protected override void Solve() { base.Solve(); if (_includeZeroInstall) { try { var selfSelections = Solver.Solve(new FeedUri(Config.DefaultSelfUpdateUri)); Selections.Implementations.Add(selfSelections.Implementations); UncachedImplementations.Add(SelectionsManager.GetUncachedImplementations(selfSelections)); } #region Error handling catch { // Suppress any left-over errors if the user canceled anyway Handler.CancellationToken.ThrowIfCancellationRequested(); throw; } #endregion Handler.CancellationToken.ThrowIfCancellationRequested(); } }
private void DownloadUncachedImplementations(IEnumerable <ImplementationSelection> selectedImplementations) { var selections = new Selections(selectedImplementations); var uncachedImplementations = SelectionsManager.GetUncachedSelections(selections).ToList(); // Do not waste time on Fetcher subsystem if nothing is missing from cache if (uncachedImplementations.Count == 0) { return; } // Only show implementations in the UI that need to be downloaded Handler.ShowSelections(new Selections(uncachedImplementations), FeedManager); try { var toDownload = SelectionsManager.GetImplementations(uncachedImplementations); Fetcher.Fetch(toDownload); } #region Error handling catch { // Suppress any left-over errors if the user canceled anyway Handler.CancellationToken.ThrowIfCancellationRequested(); throw; } #endregion }
/// <summary> /// Initializes a new instance of the <see cref="VisualBoard"/> class. /// </summary> /// <param name="piecesProvider">The pieces provider.</param> public VisualBoard(PiecesProvider piecesProvider) { _piecesProvider = piecesProvider; FriendlyBoard = new FriendlyBoard(); _selectionsManager = new SelectionsManager(); _axesManager = new AxesManager(); }
private void Run(Requirements requirements) { var selections = Solver.Solve(requirements); var missing = SelectionsManager.GetUncachedImplementations(selections); Fetcher.Fetch(missing); Executor.Start(selections); }
private void DownloadUncachedImplementations(IEnumerable <ImplementationSelection> implementations) { var uncachedImplementations = SelectionsManager.GetUncachedSelections(new Selections(implementations)).ToList(); if (uncachedImplementations.Count == 0) { return; } Handler.ShowSelections(new Selections(uncachedImplementations), FeedManager); FetchAll(SelectionsManager.GetImplementations(uncachedImplementations)); }
private Selections Solve(Requirements requirements) { var selections = Solver.Solve(requirements); if (FeedManager.ShouldRefresh || SelectionsManager.GetUncachedSelections(selections).Any()) { FeedManager.Stale = false; FeedManager.Refresh = true; selections = Solver.Solve(requirements); FeedManager.Refresh = false; } return(selections); }
protected virtual ExitCode ShowOutput() { Debug.Assert(Selections != null); if (ShowXml) { Handler.Output(Resources.SelectedImplementations, Selections.ToXmlString()); } else { Handler.Output(Resources.SelectedImplementations, SelectionsManager.GetTree(Selections)); } return(ExitCode.OK); }
/// <summary> /// Trys to generate <see cref="Selections"/> for running the specified <paramref name="command"/> without downloading anything. /// </summary> private Selections?SolveOffline(string?command) { Config.NetworkUse = NetworkLevel.Offline; try { var selections = Solver.Solve(new(InterfaceUri, command)); return(SelectionsManager.GetUncachedImplementations(selections).Any() ? null : selections); } catch (Exception ex) when(ex is SolverException or WebException) { Log.Debug("Failed to solve dependencies without downloading anything", ex); return(null); } } }
public void DownloadPackage([NotNull] string fastPackageReference, [NotNull] string location) { Directory.CreateDirectory(location); typeof(OneGetCommand).WriteEmbeddedFile("import.bat", Path.Combine(location, "import.bat")); FeedCache = new DiskFeedCache(Path.Combine(location, "interfaces"), OpenPgp); Store = new DirectoryStore(Path.Combine(location, "implementations"), useWriteProtection: false); FeedManager.Refresh = true; var requirements = ParseReference(fastPackageReference); var selections = Solve(requirements); Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections)); SelfUpdateCheck(); }
public void InstallPackage([NotNull] string fastPackageReference) { FeedManager.Refresh = Refresh; var requirements = ParseReference(fastPackageReference); var selections = Solve(requirements); if (Config.NetworkUse == NetworkLevel.Full && !DownloadLater) { Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections)); } ApplyIntegration(requirements); ApplyVersionRestrictions(requirements, selections); SelfUpdateCheck(); }
protected override void Solve() { base.Solve(); try { UncachedImplementations = SelectionsManager.GetUncachedImplementations(Selections); } #region Error handling catch (Exception ex) when(ex is KeyNotFoundException or InvalidDataException) { // Wrap exception since only certain exception types are allowed throw new SolverException(ex.Message, ex); } #endregion }
/// <summary> /// Shows a list of changes found by the update process. /// </summary> protected override ExitCode ShowOutput() { Debug.Assert(_oldSelections != null && Selections != null); var diff = SelectionsManager.GetDiff(_oldSelections, Selections).ToList(); if (diff.Count == 0) { Handler.OutputLow(Resources.NoUpdatesFound, Resources.NoUpdatesFound); return(ExitCode.NoChanges); } else { Handler.Output(Resources.ChangesFound, diff); return(ExitCode.OK); } }
public void DownloadPackage(string fastPackageReference, string location) { var requirements = ParseReference(fastPackageReference); var selections = Solve(requirements); Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections)); var exporter = new Exporter(selections, requirements, location); exporter.ExportFeeds(FeedCache, OpenPgp); exporter.ExportImplementations(ImplementationStore, Handler); exporter.DeployImportScript(); exporter.DeployBootstrapIntegrate(Handler); Yield(requirements); SelfUpdateCheck(); }
/// <summary> /// Downloads any implementations selected by the Solver that are not in the cache yet. /// </summary> private void Fetch() { var uncached = SelectionsManager.GetUncachedImplementations(_selections); Fetcher.Fetch(uncached); }
private ActionResult BuildCatalogHomeByFit(string category, string fitFilter) { string gender = null, genderFilter = null; gender = this.RouteData.Values["gender"].ToString().ToLower(); genderFilter = Constants.GenderFilterFor(gender); ViewBag.Scripts = new List <string>() { "catalog.js" }; var model = new CatalogModel(); model.Selections = SelectionsManager.GetSelectionModel(this.CurrentBrand); this.BuildBreadcrumb(model.Selections.Breadcrumb, category, null, gender, genderFilter); if (string.IsNullOrEmpty(gender) || ((model.Selections.Breadcrumb.Category == null && !model.Selections.Breadcrumb.IsCategoryForNewProds) && model.Selections.Breadcrumb.Collection == null)) { throw Utility.Exception404(); } //get filters model.Filters = FiltersManager.GetFilterModel(this.CurrentBrand, genderFilter); if (fitFilter != null) { var fit = model.Filters.FitTypes.Where(d => d.Name.ToLower() == fitFilter.ToLower()).FirstOrDefault(); if (fit != null) { fit.Selected = true; } } model.ProductList = ProductsManager.GetProducts(this.Session, new ProductListFilter() { Brand = this.CurrentBrand, ViewAll = false, PageNumber = 1, Collection = model.Selections.Breadcrumb.Collection != null ? model.Selections.Breadcrumb.Collection.Name : null, Gender = genderFilter, Category = model.Selections.Breadcrumb.Category != null ? model.Selections.Breadcrumb.Category.Name : null, IsNew = model.Selections.Breadcrumb.IsCategoryForNewProds ? "true" : null, Fit = string.IsNullOrEmpty(fitFilter) ? new List <string>() : new List <string>() { fitFilter } }); if (fitFilter == "Classic" || fitFilter == "Modern") { string fileName = fitFilter == "Classic" ? "ln_fit_classic" : "ln_fit_modern"; var arr = model.ProductList.CatalogImage.Split('/'); for (int i = 0; i < arr.Length; i++) { if (arr[i].Contains(".jpg")) { arr[i] = fileName + ".jpg"; } } model.ProductList.CatalogImage = String.Join("/", arr); } model.Filters.FilterDisplay = model.ProductList.FilterDisplay; model.Filters.FilterDisplay.DisplayFitFilter = false; model.ProductList.DisplaySlider = !((category == "other-products") || (category == "new-arrivals") || (genderFilter == Constants.WOMEN_GENDER && category == "pre-washed") || (genderFilter == Constants.MEN_GENDER && category == "pre-washed") || (genderFilter == Constants.MEN_GENDER && category == "mens-ripstop")); ViewBag.Title = model.ProductList.Seo.PageTitle; ViewBag.Description = model.ProductList.Seo.PageDescription; return(View(PathFromView("FitTypes"), model)); }
// GET: Header public ActionResult RenderHeader() { var model = SelectionsManager.GetSelectionModel(this.CurrentBrand); return(PartialView(PathFromView("Partials/_HeaderPartial"), model)); }