Exemplo n.º 1
0
    /// <summary>
    /// Creates a new solver run.
    /// </summary>
    /// <param name="requirements">The requirements to satisfy.</param>
    /// <param name="candidateProvider">Generates <see cref="SelectionCandidate"/>s for the solver to choose from.</param>
    protected SolverRunBase(Requirements requirements, ISelectionCandidateProvider candidateProvider)
    {
        if (requirements == null)
        {
            throw new ArgumentNullException(nameof(requirements));
        }
        if (requirements.InterfaceUri == null)
        {
            throw new ArgumentException(Resources.MissingInterfaceUri, nameof(requirements));
        }
        _requirements = requirements.ForCurrentSystem();

        CandidateProvider = candidateProvider;

        Selections = new Selections
        {
            InterfaceUri = requirements.InterfaceUri,
            Command      = requirements.Command
        };
    }
Exemplo n.º 2
0
    /// <inheritdoc/>
    public override ExitCode Execute()
    {
        Solve();

        var exporter = new Exporter(Selections, Requirements.ForCurrentSystem().Architecture, _outputPath ?? throw new InvalidOperationException($"Must run {nameof(Parse)}() first."));

        exporter.ExportFeeds(FeedCache, OpenPgp);

        if (!_noImplementations)
        {
            DownloadUncachedImplementations();
            exporter.ExportImplementations(ImplementationStore, Handler);
        }

        if (FeedCache.GetFeed(Requirements.InterfaceUri) is {} feed)
        {
            exporter.ExportIcons(
                feed.Icons.Concat(feed.SplashScreens),
                IconStores.DesktopIntegration(Config, Handler, machineWide: false));
        }

        exporter.DeployImportScript();
        switch (_bootstrapType)
        {
        case BootstrapMode.Run:
            exporter.DeployBootstrapRun(Handler);
            break;

        case BootstrapMode.Integrate:
            exporter.DeployBootstrapIntegrate(Handler);
            break;
        }

        BackgroundSelfUpdate();

        return(ShowOutput());
    }
Exemplo n.º 3
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 created.</exception>
 /// <exception cref="UnauthorizedAccessException">Creating the directory <paramref name="destination"/> is not permitted.</exception>
 public Exporter(Selections selections, Requirements requirements, string destination)
     : this(selections, requirements.ForCurrentSystem().Architecture, destination)
 {
 }
Exemplo n.º 4
0
 /// <inheritdoc/>
 public Selections Solve(Requirements requirements)
 {
     Log.Info($"Running Backtracking Solver for {requirements}");
     return(new SolverRun(requirements.ForCurrentSystem(), _candidateProvider).Solve());
 }