Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP use product code to lookup product install when displayName returns null #11479

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/Tools/DynamoInstallDetective/ProductLookUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ public virtual IEnumerable<string> GetProductNameList()
return s?.Contains(ProductLookUpName) ?? false;
});
}
//TODO consider adding new interface.
//Returns product names and code tuples for products which have valid display name.
internal IEnumerable<(string DisplayName, string ProductKey)> GetProductNameAndCodeList()
{
return RegUtils.GetInstalledProducts().Select(s => (s.Value.DisplayName,s.Key)).Where(s => {
return s.DisplayName?.Contains(ProductLookUpName) ?? false;
});
}

public virtual bool ExistsAtPath(string basePath)
{
Expand Down Expand Up @@ -383,9 +391,17 @@ public IInstalledProduct GetLatestProduct()

public virtual void LookUpAndInitProducts(IProductLookUp lookUp)
{
var newProducts = lookUp.GetProductNameList()
.Select(lookUp.GetProductFromProductName).Distinct()
.Where(p => p != null).OrderBy(p => p);
//TODO fallback if this cast fails
var newProducts = (lookUp as InstalledProductLookUp).GetProductNameAndCodeList()
.Select(prod =>
{
var product = lookUp.GetProductFromProductName(prod.DisplayName);
if (product == null)
{
product = lookUp.GetProductFromProductCode(prod.ProductKey);
}
return product;
}).Distinct().Where(p => p != null).OrderBy(p => p);
Products = Products == null ? newProducts : Products.Concat(newProducts);
}
}
Expand Down