Skip to content

Commit fb58e14

Browse files
committed
Starting changes for resolver
1 parent 79c4888 commit fb58e14

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

src/AppInstallerRepositoryCore/MatchCriteriaResolver.cpp

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ namespace AppInstaller::Repository
1414
return false;
1515
}
1616

17-
bool ValueMatchFunction_AlwaysTrue(const Utility::NormalizedString&, const Utility::NormalizedString&)
18-
{
19-
return true;
20-
}
21-
2217
bool ValueMatchFunction_Exact(const Utility::NormalizedString& a, const Utility::NormalizedString& b)
2318
{
2419
return a == b;
@@ -54,8 +49,6 @@ namespace AppInstaller::Repository
5449
case MatchType::Fuzzy:
5550
case MatchType::FuzzySubstring:
5651
case MatchType::Wildcard:
57-
// Benefit of the doubt here...
58-
return ValueMatchFunction_AlwaysTrue;
5952
default:
6053
return ValueMatchFunction_AlwaysFalse;
6154
}
@@ -90,13 +83,6 @@ namespace AppInstaller::Repository
9083
}
9184
}
9285

93-
// Ensures the consistency of the criteria itself.
94-
bool CheckCriteria(const PackageMatchFilter& criteria)
95-
{
96-
// Could also ensure that all enums are valid values
97-
return !criteria.Value.empty();
98-
}
99-
10086
// Ensures that the query matches the criteria.
10187
bool CheckQuery(const std::optional<RequestMatch>& query, const PackageMatchFilter& criteria)
10288
{
@@ -147,10 +133,49 @@ namespace AppInstaller::Repository
147133

148134
return true;
149135
}
136+
137+
// ----------------------- NEW
138+
139+
PackageVersionProperty GetPackageVersionPropertyFor(PackageMatchField field)
140+
{
141+
switch (field)
142+
{
143+
case PackageMatchField::Id:
144+
return PackageVersionProperty::Id;
145+
case PackageMatchField::Name:
146+
return PackageVersionProperty::Name;
147+
case PackageMatchField::Moniker:
148+
return PackageVersionProperty::Moniker;
149+
default:
150+
THROW_HR(E_UNEXPECTED);
151+
}
152+
}
153+
154+
std::optional<MatchType> GetBestMatchType(const SearchRequest& request, PackageMatchField field, const Utility::NormalizedString& value)
155+
{
156+
157+
}
150158
}
151159

152-
PackageMatchFilter FindBestMatchCriteria(const SearchRequest& request, const std::shared_ptr<ICompositePackage>& package)
160+
PackageMatchFilter FindBestMatchCriteria(const SearchRequest& request, const IPackageVersion* packageVersion)
153161
{
162+
PackageMatchFilter result{ PackageMatchField::Unknown, MatchType::Wildcard };
154163

164+
// Single value fields
165+
for (auto field : { PackageMatchField::Id, PackageMatchField::Name, PackageMatchField::Moniker })
166+
{
167+
auto propertyValue = packageVersion->GetProperty(GetPackageVersionPropertyFor(field));
168+
if (propertyValue.empty())
169+
{
170+
continue;
171+
}
172+
}
173+
174+
// Multi-value fields
175+
for (auto field : { PackageMatchField::Command, PackageMatchField::Tag, PackageMatchField::PackageFamilyName,
176+
PackageMatchField::ProductCode, PackageMatchField::UpgradeCode })
177+
{
178+
179+
}
155180
}
156181
}

src/AppInstallerRepositoryCore/MatchCriteriaResolver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
namespace AppInstaller::Repository
77
{
8-
// Finds the highest rated match criteria for the package based on the search request
9-
PackageMatchFilter FindBestMatchCriteria(const SearchRequest& request, const std::shared_ptr<ICompositePackage>& package);
8+
// Finds the highest rated match criteria for the package based on the search request,
9+
PackageMatchFilter FindBestMatchCriteria(const SearchRequest& request, const IPackageVersion* packageVersion);
1010
}

0 commit comments

Comments
 (0)