public List <DomainExportType> GetBestExports(string version) { DomainExportVersion current = Exports.SingleOrDefault(v => v.Version == version); if (current != null) { return(current.Types); } int[] numeric = convertVersion(version); int lastSum = Int32.MinValue; foreach (DomainExportVersion domainVersion in Exports) { int[] n = convertVersion(domainVersion.Version); int sum = 0; for (int i = 0; i < 4; ++i) { sum += numeric[i] - n[i] + (3 - i) * 100; } if (lastSum < 0 && sum > 0) { lastSum = sum; current = domainVersion; } else { if (lastSum > 0 && sum > 0 && sum < lastSum) { lastSum = sum; current = domainVersion; } else { if (lastSum < 0 && sum < 0 && sum > lastSum) { lastSum = sum; current = domainVersion; } } } } return(current?.Types); }
public List <DomainExportType> GetBestExports(DomainVersion version) { // // Check for exact version match // DomainExportVersion found = Exports.SingleOrDefault(v => v.Version == version); if (found != null) { return(found.Types); } // // Else look for the max of all versions less than the specified version // DomainVersion max = Exports.Where(v => v.Version < version).Max(v => v.Version); if (max != null) { found = Exports.Single(v => v.Version == max); return(found.Types); } // // Otherwise just return for the max version // max = Exports.Max(v => v.Version); if (max != null) { found = Exports.Single(v => v.Version == max); return(found.Types); } // // Otherwise there is nothing to return // return(new List <DomainExportType>()); }