private void Run(Requirements requirements) { var selections = Solver.Solve(requirements); var missing = SelectionsManager.GetUncachedImplementations(selections); Fetcher.Fetch(missing); Executor.Start(selections); }
private string GetEmailBody(Student student, Requirements emailRequirements) { var sb = new StringBuilder(); sb.Append(GetHeader(student, emailRequirements)); if (emailRequirements.HasFlag(Requirements.Fbi)) { sb.Append(GetTemplate(FbiTemplate)); } if (emailRequirements.HasFlag(Requirements.Fcsr)) { sb.Append(GetTemplate(FcsrTemplate)); } if (emailRequirements.HasFlag(Requirements.Liab)) { sb.Append(GetTemplate(LiabTemplate)); } if (emailRequirements.HasFlag(Requirements.Tb)) { sb.Append(GetTemplate(TbTemplate)); } sb.Append(GetTemplate(FooterTemplate)); return sb.ToString(); }
/// <inheritdoc/> public Selections Solve(Requirements requirements) { try { return _primarySolver.Solve(requirements); } catch (SolverException ex) { Log.Info("Primary solver failed, falling back to secondary solver."); Log.Info(ex); try { return _secondarySolver.Solve(requirements); } catch (WebException ex2) { Log.Warn("External solver failed"); Log.Info(ex2); // Report the original problem instead of inability to launch external solver throw ex.PreserveStack(); } } }
public void GetEffectiveHandlesX86OnX64() { if (Architecture.CurrentSystem.Cpu != Cpu.X64) Assert.Ignore("Can only test on X64 systems"); var requirements = new Requirements("http://test/feed.xml", Command.NameRun, new Architecture(OS.Linux, Cpu.X64)) {Languages = {"fr"}}; requirements.GetEffective().Should().Equal( new Requirements("http://test/feed.xml", Command.NameRun, new Architecture(OS.Linux, Cpu.X64)) {Languages = {"fr"}}, new Requirements("http://test/feed.xml", Command.NameRun, new Architecture(OS.Linux, Cpu.I686)) {Languages = {"fr"}}); }
/// <inheritdoc/> public AppEntry AddApp(string petName, Requirements requirements, Feed feed) { #region Sanity checks if (string.IsNullOrEmpty(petName)) throw new ArgumentNullException(nameof(petName)); if (requirements == null) throw new ArgumentNullException(nameof(requirements)); if (feed == null) throw new ArgumentNullException(nameof(feed)); #endregion var appEntry = AddAppInternal(petName, requirements, feed); Finish(); return appEntry; }
public MailMessage GenerateEmail(Student student, Requirements emailRequirements) { var mailMessage = new MailMessage(Environment.UserName + "@missouristate.edu", student.Email) { Subject = EmailSubject, SubjectEncoding = Encoding.UTF8, BodyEncoding = Encoding.UTF8, IsBodyHtml = true, Body = GetEmailBody(student, emailRequirements) }; return mailMessage; }
/// <inheritdoc/> public Selections Solve(Requirements requirements) { try { return _primarySolver.Solve(requirements); } catch (SolverException ex) { Log.Info(string.Format("Primary solver reported: " + ex.Message + Environment.NewLine + "Falling back to secondary solver.", requirements)); Log.Info(ex); return _secondarySolver.Solve(requirements); } }
public static ImplementationVersion SilentCheck() { var services = new ServiceLocator(new SilentTaskHandler()) {FeedManager = {Refresh = true}}; if (services.Config.NetworkUse == NetworkLevel.Offline) return null; // Run solver var requirements = new Requirements(services.Config.SelfUpdateUri); var selections = services.Solver.Solve(requirements); // Report version of current update if it is newer than the already installed version var currentVersion = new ImplementationVersion(AppInfo.CurrentLibrary.Version); var newVersion = selections.MainImplementation.Version; return (newVersion > currentVersion) ? newVersion : null; }
/// <inheritdoc/> public Selections Solve(Requirements requirements) { #region Sanity checks if (requirements == null) throw new ArgumentNullException(nameof(requirements)); if (requirements.InterfaceUri == null) throw new ArgumentException(Resources.MissingInterfaceUri, nameof(requirements)); #endregion Log.Info("Running Backtracking Solver for: " + requirements); var effectiveRequirements = requirements.GetEffective(); var candidateProvider = new SelectionCandidateProvider(_config, _feedManager, _store, _packageManager, requirements.Languages); var solverRuns = effectiveRequirements.Select(x => new Pass(x, _handler.CancellationToken, candidateProvider)); var successfullSolverRun = solverRuns.FirstOrDefault(x => x.TryToSolve()); if (successfullSolverRun == null) throw new SolverException("No solution found"); successfullSolverRun.Selections.PurgeRestrictions(); successfullSolverRun.Selections.Implementations.Sort(); return successfullSolverRun.Selections; }
/// <summary> /// Creates a new external JSON solver. /// </summary> /// <param name="backingSolver">An internal solver used to find an implementation of the external solver.</param> /// <param name="selectionsManager">Used to check whether the external solver is already in the cache.</param> /// <param name="fetcher">Used to download implementations of the external solver.</param> /// <param name="executor">Used to launch the external solver.</param> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public ExternalSolver([NotNull] ISolver backingSolver, [NotNull] ISelectionsManager selectionsManager, [NotNull] IFetcher fetcher, [NotNull] IExecutor executor, [NotNull] Config config, [NotNull] IFeedManager feedManager, [NotNull] ITaskHandler handler) { #region Sanity checks if (backingSolver == null) throw new ArgumentNullException(nameof(backingSolver)); if (selectionsManager == null) throw new ArgumentNullException(nameof(selectionsManager)); if (fetcher == null) throw new ArgumentNullException(nameof(fetcher)); if (executor == null) throw new ArgumentNullException(nameof(executor)); if (config == null) throw new ArgumentNullException(nameof(config)); if (feedManager == null) throw new ArgumentNullException(nameof(feedManager)); if (handler == null) throw new ArgumentNullException(nameof(handler)); #endregion _backingSolver = backingSolver; _selectionsManager = selectionsManager; _fetcher = fetcher; _executor = executor; _feedManager = feedManager; _handler = handler; _solverRequirements = new Requirements(config.ExternalSolverUri); }
public Requirements DetermineEmails(Student student, Requirements requirements, DateTime cutOff) { var emailsNeeded = Requirements.None; if (requirements.HasFlag(Requirements.Fbi)) { if ( !student.FbiExpiration.Split(',') .Aggregate(false, (current, date) => current || IsCleared(date, cutOff))) { emailsNeeded |= Requirements.Fbi; } } if (requirements.HasFlag(Requirements.Fcsr)) { if (string.IsNullOrEmpty(student.FcsrExpiration) || string.IsNullOrEmpty(student.FcsrExpiration.Trim())) { emailsNeeded |= Requirements.Fcsr; } } if (requirements.HasFlag(Requirements.Liab)) { if (!IsCleared(student.LiabExpiration, cutOff)) { emailsNeeded |= Requirements.Liab; } } if (requirements.HasFlag(Requirements.Tb)) { if (!IsCleared(student.TbExpiration, cutOff)) { emailsNeeded |= Requirements.Tb; } } return emailsNeeded; }
/// <inheritdoc/> public Selection([NotNull] ICommandHandler handler) : base(handler) { Requirements = new Requirements(); Options.Add("customize", () => Resources.OptionCustomize, _ => CustomizeSelections = true); Options.Add("o|offline", () => Resources.OptionOffline, _ => Config.NetworkUse = NetworkLevel.Offline); Options.Add("r|refresh", () => Resources.OptionRefresh, _ => FeedManager.Refresh = true); Options.Add("with-store=", () => Resources.OptionWithStore, delegate(string path) { if (string.IsNullOrEmpty(path)) throw new OptionException(string.Format(Resources.MissingOptionValue, "--with-store"), "with-store"); Store = new CompositeStore(new[] {new DirectoryStore(path), Store}); }); Options.Add("command=", () => Resources.OptionCommand, command => Requirements.Command = command); Options.Add("before=", () => Resources.OptionBefore, (ImplementationVersion version) => _before = version); Options.Add("not-before=", () => Resources.OptionNotBefore, (ImplementationVersion version) => _notBefore = version); Options.Add("version=", () => Resources.OptionVersionRange, (VersionRange range) => _version = range); Options.Add("version-for==", () => Resources.OptionVersionRangeFor, (FeedUri interfaceUri, VersionRange range) => Requirements.ExtraRestrictions[interfaceUri] = range); Options.Add("s|source", () => Resources.OptionSource, _ => Requirements.Source = true); Options.Add("os=", () => Resources.OptionOS + "\n" + SupportedValues(Architecture.KnownOS), (OS os) => Requirements.Architecture = new Architecture(os, Requirements.Architecture.Cpu)); Options.Add("cpu=", () => Resources.OptionCpu + "\n" + SupportedValues(Architecture.KnownCpu), (Cpu cpu) => Requirements.Architecture = new Architecture(Requirements.Architecture.OS, cpu)); Options.Add("language=", () => Resources.OptionLanguage, (CultureInfo lang) => Requirements.Languages.Add(lang)); Options.Add("xml", () => Resources.OptionXml, _ => ShowXml = true); }
public bool IsCleared(Domain.Student student, Requirements requirements) { if (requirements.HasFlag(Requirements.Fbi)) { return IsFbiCleared(student.FbiExpiration); } if (requirements.HasFlag(Requirements.Fcsr)) { return IsFcsrCleared(student.FcsrExpiration); } if (requirements.HasFlag(Requirements.Liab)) { return IsLiabCleared(student.LiabExpiration); } if (requirements.HasFlag(Requirements.Tb)) { return IsTbCleared(student.TbExpiration); } return true; }
public PlankscurveRecipe() : base("plankscurverecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("planks", 1)); Result.Add(new InventoryItem("plankscurve", 1)); }
public clayblockcyancurverotatedRecipe() : base("clayblockcyancurverotatedrecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblockcyancurverotated", 1)); }
public bricksupsidedownslopeinsidecornerRecipe() : base("bricksupsidedownslopeinsidecornerrecipe") { Requirements.Add(new InventoryItem("stonebricks", 1)); Result.Add(new InventoryItem("bricksupsidedownslopeinsidecorner", 1)); }
public bricksfourstepstairsRecipe() : base("bricksfourstepstairsrecipe") { Requirements.Add(new InventoryItem("stonebricks", 1)); Result.Add(new InventoryItem("bricksfourstepstairs", 1)); }
public clayblockcyanslopecorneredgeRecipe() : base("clayblockcyanslopecorneredgerecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblockcyanslopecorneredge", 1)); }
/// <inheritdoc/> public Selections Solve(Requirements requirements) { #region Sanity checks if (requirements == null) throw new ArgumentNullException("requirements"); if (requirements.InterfaceUri == null) throw new ArgumentException(Resources.MissingInterfaceUri, "requirements"); #endregion Log.Info("Running Python Solver for: " + requirements); // Execute the external solver ISolverControl control; if (WindowsUtils.IsWindows) control = new SolverControlBundled(_handler); // Use bundled Python on Windows else control = new SolverControlNative(_handler); // Use native Python everywhere else var arguments = GetSolverArguments(requirements); string result = null; _handler.RunTask(new SimpleTask(Resources.ExternalSolverRunning, () => { result = control.Execute(arguments); })); // Flush in-memory cache in case external solver updated something on-disk _feedCache.Flush(); // Detect when feeds get out-of-date _feedManager.Stale = result.Contains("<!-- STALE_FEEDS -->"); // Parse StandardOutput data as XML _handler.CancellationToken.ThrowIfCancellationRequested(); try { var selections = XmlStorage.FromXmlString<Selections>(result); selections.Normalize(); return selections; } #region Error handling catch (InvalidDataException ex) { Log.Warn("Solver result:" + Environment.NewLine + result); throw new SolverException(Resources.ExternalSolverOutputErrror, ex); } #endregion }
public ironblockcurvecornerRecipe() : base("ironblockcurvecornerrecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("ironblock", 1)); Result.Add(new InventoryItem("ironblockcurvecorner", 1)); }
private static void ApplyVersionRestrictions(Requirements requirements, Selections selections) { if (requirements.ExtraRestrictions.Count == 0) return; // TODO Log.Warn(string.Format("You have applied a version restriction to this app. Zero Install will continue to apply this restriction to any future updates. You will need to run '0install select --customize {0}' to undo this.", requirements.InterfaceUri)); foreach (var restriction in requirements.ExtraRestrictions) { var selection = selections.GetImplementation(restriction.Key); if (selection != null) { var pref = FeedPreferences.LoadForSafe(restriction.Key); pref.Implementations.Clear(); pref[selection.ID].UserStability = Stability.Preferred; pref.SaveFor(restriction.Key); } } }
public void FindPackageBy(string identifier) { FeedManager.Refresh = Refresh; var uri = GetCanonicalUri(identifier); var requirements = new Requirements(uri); Yield(requirements); }
private IDictionary<FeedUri, Feed> GetFeeds(Requirements requirements) { var dictionary = new Dictionary<FeedUri, Feed>(); AddFeed(dictionary, requirements.InterfaceUri, requirements); foreach (var uri in GetNativeFeedPaths(requirements.InterfaceUri)) AddFeed(dictionary, uri, requirements); foreach (var uri in GetSitePackagePaths(requirements.InterfaceUri)) AddFeed(dictionary, uri, requirements); foreach (var reference in _interfacePreferences[requirements.InterfaceUri].Feeds) { try { AddFeed(dictionary, reference.Source, requirements); } #region Error handling catch (IOException ex) { // Wrap exception to add context information throw new IOException( string.Format("Failed to load feed {1} manually registered for interface {0}. Try '0install remove-feed {0} {1}.", requirements.InterfaceUri.ToStringRfc(), reference.Source.ToStringRfc()), ex); } #endregion } return dictionary; }
private IEnumerable<SelectionCandidate> GetCandidates(FeedUri feedUri, Feed feed, Requirements requirements) { var feedPreferences = FeedPreferences.LoadForSafe(feedUri); foreach (var element in feed.Elements) { var implementation = element as Implementation; if (implementation != null) { // Each <implementation> provides 1 selection candidate yield return new SelectionCandidate(feedUri, feedPreferences, implementation, requirements, offlineUncached: (_config.NetworkUse == NetworkLevel.Offline) && !_isCached(implementation)); } else { var packageImplementation = element as PackageImplementation; if (packageImplementation != null) { // Each <package-implementation> provides 0..n selection candidates var externalImplementations = _packageManager.Query(packageImplementation, requirements.Distributions.ToArray()); foreach (var externalImplementation in externalImplementations) { _externalImplementations[externalImplementation.ID] = externalImplementation; yield return new SelectionCandidate(new FeedUri(FeedUri.FromDistributionPrefix + feedUri), feedPreferences, externalImplementation, requirements); } } } } }
private void AddFeed(IDictionary<FeedUri, Feed> dictionary, FeedUri feedUri, Requirements requirements) { if (feedUri == null || dictionary.ContainsKey(feedUri)) return; var feed = _feeds[feedUri]; if (feed.MinInjectorVersion != null && new ImplementationVersion(AppInfo.Current.Version) < feed.MinInjectorVersion) { Log.Warn(string.Format("The solver version is too old. The feed '{0}' requires at least version {1} but the installed version is {2}. Try updating Zero Install.", feedUri, feed.MinInjectorVersion, AppInfo.Current.Version)); return; } dictionary.Add(feedUri, feed); foreach (var reference in feed.Feeds) { if (reference.Architecture.IsCompatible(requirements.Architecture) && (reference.Languages.Count == 0 || reference.Languages.ContainsAny(requirements.Languages, ignoreCountry: true))) AddFeed(dictionary, reference.Source, requirements); } }
public static Requirements ToRequirements([NotNull] this Runner runner, [NotNull] Requirements topLevelRequirements) { #region Sanity checks if (runner == null) throw new ArgumentNullException("runner"); if (topLevelRequirements == null) throw new ArgumentNullException("topLevelRequirements"); #endregion var requirements = new Requirements(runner.InterfaceUri, runner.Command ?? Command.NameRun, topLevelRequirements.Architecture); requirements.CopyVersionRestrictions(from: runner); requirements.CopyVersionRestrictions(from: topLevelRequirements); return requirements; }
public static Requirements ToRequirements([NotNull] this Restriction dependency, [NotNull] Requirements topLevelRequirements) { #region Sanity checks if (dependency == null) throw new ArgumentNullException("dependency"); if (topLevelRequirements == null) throw new ArgumentNullException("topLevelRequirements"); #endregion var requirements = new Requirements(dependency.InterfaceUri, "", topLevelRequirements.Architecture); requirements.Distributions.AddRange(dependency.Distributions); requirements.CopyVersionRestrictions(from: dependency); requirements.CopyVersionRestrictions(from: topLevelRequirements); return requirements; }
/// <summary> /// Loads a feed and adds it to a dictionary if it is not already in it. Recursivley adds <see cref="Feed.Feeds"/> references. /// </summary> /// <param name="dictionary">The dictionary to add the feed to.</param> /// <param name="feedUri">The URI to load the feed from</param> /// <param name="requirements">Requirements to apply as a filter to <see cref="Feed.Feeds"/> references before following them.</param> private void AddFeedToDict([NotNull] IDictionary <FeedUri, Feed> dictionary, [CanBeNull] FeedUri feedUri, [NotNull] Requirements requirements) { if (feedUri == null || dictionary.ContainsKey(feedUri)) { return; } var feed = _feedManager[feedUri]; if (feed.MinInjectorVersion != null && FeedElement.ZeroInstallVersion < feed.MinInjectorVersion) { Log.Warn($"The solver version is too old. The feed '{feedUri}' requires at least version {feed.MinInjectorVersion} but the installed version is {FeedElement.ZeroInstallVersion}. Try updating Zero Install."); return; } dictionary.Add(feedUri, feed); foreach (var reference in feed.Feeds) { if (reference.Architecture.IsCompatible(requirements.Architecture) && (reference.Languages.Count == 0 || reference.Languages.ContainsAny(requirements.Languages, ignoreCountry: true))) { AddFeedToDict(dictionary, reference.Source, requirements); } } }
public stonebricksupsidedownslopecornerRecipe() : base("stonebricksupsidedownslopecornerrecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("stonebricks", 1)); Result.Add(new InventoryItem("stonebricksupsidedownslopecorner", 1)); }
private void ApplyIntegration(Requirements requirements) { Log.Info("Applying desktop integration"); var feed = FeedManager.GetFeed(requirements.InterfaceUri); using (var integrationManager = new CategoryIntegrationManager(Handler, _machineWide)) { var appEntry = integrationManager.AddApp(new FeedTarget(requirements.InterfaceUri, feed)); integrationManager.AddAccessPointCategories(appEntry, feed, CategoryIntegrationManager.StandardCategories); } }
public stonebricksfourstepstairsinsidecornerRecipe() : base("stonebricksfourstepstairsinsidecornerrecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("stonebricks", 1)); Result.Add(new InventoryItem("stonebricksfourstepstairsinsidecorner", 1)); }
private void CatalogSearch([CanBeNull] string name, [CanBeNull] VersionRange versionRange) { foreach (var feed in GetCatalogResults(name)) { if (AllVersions) { foreach (var implementation in FeedManager.GetFeedFresh(feed.Uri).Elements.OfType<Implementation>()) { var requirements = new Requirements(feed.Uri) {ExtraRestrictions = {{feed.Uri, new VersionRange(implementation.Version)}}}; Yield(requirements, feed, implementation); } } else { var requirements = new Requirements(feed.Uri); if (versionRange != null) requirements.ExtraRestrictions[requirements.InterfaceUri] = versionRange; Yield(requirements, feed); } } }
public plasterblockupsidedowncurvecornerRecipe() : base("plasterblockupsidedowncurvecornerrecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("plasterblock", 1)); Result.Add(new InventoryItem("plasterblockupsidedowncurvecorner", 1)); }
private void MirrorSearch([CanBeNull] string name, [CanBeNull] VersionRange versionRange) { foreach (var result in SearchQuery.Perform(Config, name).Results) { var requirements = new Requirements(result.Uri); if (versionRange != null) requirements.ExtraRestrictions[requirements.InterfaceUri] = versionRange; Yield(requirements, result.ToPseudoFeed()); } }
public redplanksfourstepstairscornerRecipe() : base("redplanksfourstepstairscornerrecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("redplanks", 1)); Result.Add(new InventoryItem("redplanksfourstepstairscorner", 1)); }
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; }
public plasterblockspikeRecipe() : base("plasterblockspikerecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("plasterblock", 1)); Result.Add(new InventoryItem("plasterblockspike", 1)); }
public bool Equals(DestinyRecordDefinition input) { if (input == null) { return(false); } return (( DisplayProperties == input.DisplayProperties || (DisplayProperties != null && DisplayProperties.Equals(input.DisplayProperties)) ) && ( Scope == input.Scope || (Scope != null && Scope.Equals(input.Scope)) ) && ( PresentationInfo == input.PresentationInfo || (PresentationInfo != null && PresentationInfo.Equals(input.PresentationInfo)) ) && ( LoreHash == input.LoreHash || (LoreHash.Equals(input.LoreHash)) ) && ( ObjectiveHashes == input.ObjectiveHashes || (ObjectiveHashes != null && ObjectiveHashes.SequenceEqual(input.ObjectiveHashes)) ) && ( RecordValueStyle == input.RecordValueStyle || (RecordValueStyle != null && RecordValueStyle.Equals(input.RecordValueStyle)) ) && ( ForTitleGilding == input.ForTitleGilding || (ForTitleGilding != null && ForTitleGilding.Equals(input.ForTitleGilding)) ) && ( TitleInfo == input.TitleInfo || (TitleInfo != null && TitleInfo.Equals(input.TitleInfo)) ) && ( CompletionInfo == input.CompletionInfo || (CompletionInfo != null && CompletionInfo.Equals(input.CompletionInfo)) ) && ( StateInfo == input.StateInfo || (StateInfo != null && StateInfo.Equals(input.StateInfo)) ) && ( Requirements == input.Requirements || (Requirements != null && Requirements.Equals(input.Requirements)) ) && ( ExpirationInfo == input.ExpirationInfo || (ExpirationInfo != null && ExpirationInfo.Equals(input.ExpirationInfo)) ) && ( IntervalInfo == input.IntervalInfo || (IntervalInfo != null && IntervalInfo.Equals(input.IntervalInfo)) ) && ( RewardItems == input.RewardItems || (RewardItems != null && RewardItems.SequenceEqual(input.RewardItems)) ) && ( PresentationNodeType == input.PresentationNodeType || (PresentationNodeType != null && PresentationNodeType.Equals(input.PresentationNodeType)) ) && ( TraitIds == input.TraitIds || (TraitIds != null && TraitIds.SequenceEqual(input.TraitIds)) ) && ( TraitHashes == input.TraitHashes || (TraitHashes != null && TraitHashes.SequenceEqual(input.TraitHashes)) ) && ( ParentNodeHashes == input.ParentNodeHashes || (ParentNodeHashes != null && ParentNodeHashes.SequenceEqual(input.ParentNodeHashes)) ) && ( Hash == input.Hash || (Hash.Equals(input.Hash)) ) && ( Index == input.Index || (Index.Equals(input.Index)) ) && ( Redacted == input.Redacted || (Redacted != null && Redacted.Equals(input.Redacted)) )); }
public OrangeWoolRecipe() : base("Test.Orangewool", "pipliz.crafter", false, 10, 1) { Requirements.Add(new InventoryItem("flax", 1)); Result.Add(new InventoryItem("OrangeWool", 1)); }
public clayblockblackfourstepstairsinsidecornerRecipe() : base("clayblockblackfourstepstairsinsidecornerrecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblockblackfourstepstairsinsidecorner", 1)); }
public clayblocksilverupsidedownslopeRecipe() : base("clayblocksilverupsidedownsloperecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblocksilverupsidedownslope", 1)); }
public clayblockorangeupsidedownslopeinsidecornerRecipe() : base("clayblockorangeupsidedownslopeinsidecornerrecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblockorangeupsidedownslopeinsidecorner", 1)); }
public stonebrickscurverotatedRecipe() : base("stonebrickscurverotatedrecipe") { Requirements.Add(new InventoryItem("stonebricks", 1)); Result.Add(new InventoryItem("stonebrickscurverotated", 1)); }
public void RegenerateProgress() { AppearanceComponent appearance; if (!HasBoard) { if (Owner.TryGetComponent(out appearance)) { appearance.SetData(MachineFrameVisuals.State, 1); } Requirements = null; MaterialRequirements = null; ComponentRequirements = null; _progress = null; _materialProgress = null; _componentProgress = null; return; } var board = _boardContainer.ContainedEntities[0]; if (!board.TryGetComponent <MachineBoardComponent>(out var machineBoard)) { return; } if (Owner.TryGetComponent(out appearance)) { appearance.SetData(MachineFrameVisuals.State, 2); } ResetProgressAndRequirements(machineBoard); foreach (var part in _partContainer.ContainedEntities) { if (part.TryGetComponent <MachinePartComponent>(out var machinePart)) { // Check this is part of the requirements... if (!Requirements.ContainsKey(machinePart.PartType)) { continue; } if (!_progress.ContainsKey(machinePart.PartType)) { _progress[machinePart.PartType] = 1; } else { _progress[machinePart.PartType]++; } } if (part.TryGetComponent <StackComponent>(out var stack)) { var type = stack.StackTypeId; // Check this is part of the requirements... if (!MaterialRequirements.ContainsKey(type)) { continue; } if (!_materialProgress.ContainsKey(type)) { _materialProgress[type] = 1; } else { _materialProgress[type]++; } } // I have many regrets. foreach (var(compName, amount) in ComponentRequirements) { var registration = _componentFactory.GetRegistration(compName); if (!part.HasComponent(registration.Type)) { continue; } if (!_componentProgress.ContainsKey(compName)) { _componentProgress[compName] = 1; } else { _componentProgress[compName]++; } } } }
private IEnumerable <SelectionCandidate> GetCandidates(FeedUri feedUri, Feed feed, Requirements requirements) { var feedPreferences = FeedPreferences.LoadForSafe(feedUri); foreach (var element in feed.Elements) { var packageImplementation = element as PackageImplementation; if (packageImplementation != null) { // Each <package-implementation> provides 0..n selection candidates var externalImplementations = _packageManager.Query(packageImplementation, requirements.Distributions.ToArray()); foreach (var externalImplementation in externalImplementations) { _externalImplementations[externalImplementation.ID] = externalImplementation; yield return(new SelectionCandidate(new FeedUri(FeedUri.FromDistributionPrefix + feedUri), feedPreferences, externalImplementation, requirements)); } } else if (requirements.Distributions.ContainsOrEmpty(Restriction.DistributionZeroInstall)) { var implementation = element as Implementation; if (implementation != null) { // Each <implementation> provides 1 selection candidate yield return(new SelectionCandidate(feedUri, feedPreferences, implementation, requirements, offlineUncached: (_config.NetworkUse == NetworkLevel.Offline) && !_isCached(implementation))); } } } }
public AuthorizationPolicyBuilder RequireAuthenticatedUser() { Requirements.Add(new DenyAnonymousAuthorizationRequirement()); return(this); }
public HttpResponseMessage Post(Requirements objRequirement) { //Logic }
public clayblocklightblueslopecornerRecipe() : base("clayblocklightblueslopecornerrecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblocklightblueslopecorner", 1)); }
private JObject GenerateJson() { var j = new JObject( new JProperty("w", Width), new JProperty("h", Height), new JProperty("x", X), new JProperty("y", Y), new JProperty("name", NameLine), new JProperty("typeLine", TypeLine), new JProperty("frameType", Frame) ); if (_iconUrl != null) { j["icon"] = _iconUrl; } if (Properties.Count > 0) { j.Add(new JProperty("properties", new JArray(Properties.Select(p => p.ToJobject()).ToArray()))); } if (Requirements.Count > 0) { j.Add(new JProperty("requirements", new JArray(Requirements.Select(p => p.ToJobject()).ToArray()))); } if (ImplicitMods.Count > 0) { j.Add(new JProperty("implicitMods", new JArray(ImplicitMods.Select(p => p.ToJobject(true)).ToArray()))); } if (ExplicitMods.Count > 0) { j.Add(new JProperty("explicitMods", new JArray(ExplicitMods.Select(p => p.ToJobject(true)).ToArray()))); } if (CraftedMods.Count > 0) { j.Add(new JProperty("craftedMods", new JArray(CraftedMods.Select(p => p.ToJobject(true)).ToArray()))); } if (Gems.Count > 0) { var sockets = new JArray(); var socketedItems = new JArray(); foreach (var gem in Gems) { sockets.Add(new JObject { { "group", gem.SocketGroup } }); socketedItems.Add(gem.JsonBase); } j["sockets"] = sockets; j["socketedItems"] = socketedItems; } if (HaveFlavourText) { j.Add("flavourText", new JArray(FlavourText)); } return(j); }
/// <summary> /// Generates a list of arguments to be passed on to the solver script. /// </summary> /// <param name="requirements">A set of requirements/restrictions imposed by the user on the implementation selection process.</param> /// <returns>A list of arguments terminated by a space.</returns> private string[] GetSolverArguments(Requirements requirements) { var arguments = requirements.ToCommandLineArgs(); for (int i = 0; i < (int)_handler.Verbosity; i++) arguments = arguments.Prepend("--verbose"); if (_config.NetworkUse == NetworkLevel.Offline) arguments = arguments.Prepend("--offline"); if (_feedManager.Refresh) arguments = arguments.Prepend("--refresh"); return arguments; }
protected override void PrepareTechGroup(Requirements requirements) { requirements.AddGroup <TechGroupIndustryT2>(completion: 1); }
public Requirements DetermineEmails(Domain.Student student, Requirements requirements, DateTime cutOff) { throw new NotImplementedException(); }
public ClayBlockBrownRecipe() : base("clayblockbluerecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblockbrown", 1)); }
protected override void PrepareTechGroup(Requirements requirements) { requirements.AddGroup <TechGroupFarming>(completion: 0.4); requirements.AddGroup <TechGroupCooking>(completion: 0.4); }
public bool IsCleared(Student student, Requirements requirements) { throw new NotImplementedException(); }
public plankstwostepstairsRecipe() : base("plankstwostepstairsrecipe", "phentrixgames.woodcarver", false, 10, 1) { Requirements.Add(new InventoryItem("planks", 1)); Result.Add(new InventoryItem("plankstwostepstairs", 1)); }
async Task <bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { if (!HasBoard && eventArgs.Using.TryGetComponent <MachineBoardComponent>(out var machineBoard)) { if (eventArgs.Using.TryRemoveFromContainer()) { // Valid board! _boardContainer.Insert(eventArgs.Using); // Setup requirements and progress... ResetProgressAndRequirements(machineBoard); if (Owner.TryGetComponent <AppearanceComponent>(out var appearance)) { appearance.SetData(MachineFrameVisuals.State, 2); } if (Owner.TryGetComponent(out ConstructionComponent construction)) { // So prying the components off works correctly. construction.ResetEdge(); } return(true); } } else if (HasBoard) { if (eventArgs.Using.TryGetComponent <MachinePartComponent>(out var machinePart)) { if (!Requirements.ContainsKey(machinePart.PartType)) { return(false); } if (_progress[machinePart.PartType] != Requirements[machinePart.PartType] && eventArgs.Using.TryRemoveFromContainer() && _partContainer.Insert(eventArgs.Using)) { _progress[machinePart.PartType]++; return(true); } } if (eventArgs.Using.TryGetComponent <StackComponent>(out var stack)) { var type = stack.StackTypeId; if (!MaterialRequirements.ContainsKey(type)) { return(false); } if (_materialProgress[type] == MaterialRequirements[type]) { return(false); } var needed = MaterialRequirements[type] - _materialProgress[type]; var count = stack.Count; if (count < needed && stack.Split(count, Owner.Transform.Coordinates, out var newStack)) { _materialProgress[type] += count; return(true); } if (!stack.Split(needed, Owner.Transform.Coordinates, out newStack)) { return(false); } if (!_partContainer.Insert(newStack)) { return(false); } _materialProgress[type] += needed; return(true); } foreach (var(compName, info) in ComponentRequirements) { if (_componentProgress[compName] >= info.Amount) { continue; } var registration = _componentFactory.GetRegistration(compName); if (!eventArgs.Using.HasComponent(registration.Type)) { continue; } if (!eventArgs.Using.TryRemoveFromContainer() || !_partContainer.Insert(eventArgs.Using)) { continue; } _componentProgress[compName]++; return(true); } } return(false); }
/// <inheritdoc/> public void UpdateApp(AppEntry appEntry, Feed feed, Requirements requirements) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException("appEntry"); if (feed == null) throw new ArgumentNullException("feed"); if (requirements == null) throw new ArgumentNullException("requirements"); #endregion try { appEntry.Requirements = requirements; UpdateAppInternal(appEntry, feed); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new InvalidDataException(ex.Message, ex); } finally { Finish(); } }
/// <inheritdoc/> protected override AppEntry AddAppInternal(string petName, Requirements requirements, Feed feed) { #region Sanity checks if (string.IsNullOrEmpty(petName)) throw new ArgumentNullException("petName"); if (requirements == null) throw new ArgumentNullException("requirements"); if (feed == null) throw new ArgumentNullException("feed"); #endregion throw new NotImplementedException(); /* // Prevent double entries if (AppList.ContainsEntry(petName)) throw new InvalidOperationException(string.Format(Resources.AppAlreadyInList, feed.Name)); // Get basic metadata and copy of capabilities from feed var appEntry = new AppEntry {InterfaceUri = petName, Requirements = requirements, Name = feed.Name, Timestamp = DateTime.UtcNow}; appEntry.CapabilityLists.AddRange(feed.CapabilityLists.CloneElements()); AppList.Entries.Add(appEntry); WriteAppDir(appEntry); return appEntry; */ }
public clayblockblacktwostepstairsRecipe() : base("clayblockblacktwostepstairsrecipe", "pipliz.stonemason", false, 10, 1) { Requirements.Add(new InventoryItem("clay", 1)); Result.Add(new InventoryItem("clayblockblacktwostepstairs", 1)); }