diff --git a/StabilityMatrix/Helper/PackageFactory.cs b/StabilityMatrix/Helper/PackageFactory.cs index f5535ffc..1c32a9de 100644 --- a/StabilityMatrix/Helper/PackageFactory.cs +++ b/StabilityMatrix/Helper/PackageFactory.cs @@ -7,20 +7,23 @@ namespace StabilityMatrix.Helper; public class PackageFactory : IPackageFactory { - private readonly IEnumerable basePackages; + /// + /// Mapping of package.Name to package + /// + private readonly Dictionary basePackages; public PackageFactory(IEnumerable basePackages) { - this.basePackages = basePackages; + this.basePackages = basePackages.ToDictionary(x => x.Name); } public IEnumerable GetAllAvailablePackages() { - return basePackages; + return basePackages.Values; } public BasePackage? FindPackageByName(string packageName) { - return basePackages.FirstOrDefault(x => x.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase)); + return basePackages.GetValueOrDefault(packageName); } }