/// <summary> /// Gets all <see cref="SelectionCandidate"/>s for the <paramref name="demand"/> that are compatible with the current <see cref="Selections"/> state. /// </summary> private IEnumerable <SelectionCandidate> GetCompatibleCandidates(SolverDemand demand) => demand.Candidates.Where(candidate => { if (!candidate.IsSuitable) { return(false); } var nativeImplementation = candidate.Implementation as ExternalImplementation; // Ensure the candidate does not conflict with restrictions of existing selections foreach (var restriction in Selections.RestrictionsFor(demand.Requirements.InterfaceUri)) { // Prevent mixing of 32-bit and 64-bit binaries if (candidate.Implementation.Architecture.Cpu.Is32Bit() && Selections.Is64Bit) { return(false); } if (candidate.Implementation.Architecture.Cpu.Is64Bit() && Selections.Is32Bit) { return(false); } if (restriction.Versions != null && !restriction.Versions.Match(candidate.Version)) { return(false); } if (nativeImplementation != null && !restriction.Distributions.ContainsOrEmpty(nativeImplementation.Distribution)) { return(false); } } // Ensure the existing selections do not conflict with restrictions of the candidate foreach (var restriction in candidate.Implementation.GetEffectiveRestrictions()) { var selection = Selections.GetImplementation(restriction.InterfaceUri); if (selection != null) { if (restriction.Versions != null && !restriction.Versions.Match(selection.Version)) { return(false); } if (nativeImplementation != null && !restriction.Distributions.ContainsOrEmpty(nativeImplementation.Distribution)) { return(false); } } } return(true); });