/// <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 Backtracking Solver for: " + requirements);

            var effectiveRequirements = requirements.GetEffective();
            var candidateProvider     = new SelectionCandidateProvider(_config, _feedManager, _store, _packageManager);
            var solverRuns            = effectiveRequirements.Select(x => new BacktrackingSolverRun(x, _handler.CancellationToken, candidateProvider));

            var successfullSolverRun = solverRuns.FirstOrDefault(x => x.TryToSolve());
            if (successfullSolverRun == null)
            {
                throw new SolverException("No solution found");
            }

            successfullSolverRun.Selections.PurgeRestrictions();
            return(successfullSolverRun.Selections);
        }
Exemplo n.º 2
0
        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"}});
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
        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" }
            });
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new exporter.
 /// </summary>
 /// <param name="selections">A list of <see cref="ImplementationSelection"/>s to check for referenced feeds.</param>
 /// <param name="requirements">The <see cref="Requirements"/> used to generate the <see cref="Selections"/>.</param>
 /// <param name="destination">The path of the directory to export to.</param>
 /// <exception cref="IOException">The directory <paramref name="destination"/> could not be createdor.</exception>
 /// <exception cref="UnauthorizedAccessException">Creating the directory <paramref name="destination"/> is not permitted.</exception>
 public Exporter([NotNull] Selections selections, [NotNull] Requirements requirements, [NotNull] string destination)
     : this(selections, requirements.GetEffective().First().Architecture, destination)
 {
 }