@@ -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}
0 commit comments