public static TemplateToPackMap FromPackToTemplateDictionary(IReadOnlyDictionary <string, PackToTemplateEntry> templateDictionary) { Dictionary <string, PackInfo> identityToPackMap = new Dictionary <string, PackInfo>(StringComparer.OrdinalIgnoreCase); Dictionary <string, PackInfo> groupIdentityToPackMap = new Dictionary <string, PackInfo>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair <string, PackToTemplateEntry> entry in templateDictionary) { PackInfo packAndVersion = new PackInfo(entry.Key, entry.Value.Version, entry.Value.TotalDownloads); foreach (TemplateIdentificationEntry templateIdentityInfo in entry.Value.TemplateIdentificationEntry) { // Empty entries for the identity or group identity are authoring errors. // Here, they're just filtered to prevent them from being matched as empty string. if (!string.IsNullOrEmpty(templateIdentityInfo.Identity)) { identityToPackMap[templateIdentityInfo.Identity] = packAndVersion; } if (!string.IsNullOrEmpty(templateIdentityInfo.GroupIdentity)) { groupIdentityToPackMap[templateIdentityInfo.GroupIdentity] = packAndVersion; } } } return(new TemplateToPackMap(identityToPackMap, groupIdentityToPackMap)); }
public bool TryGetPackInfoForTemplateGroupIdentity(string templateName, out PackInfo packAndVersion) { if (_groupIdentityToPackMap.TryGetValue(templateName, out packAndVersion)) { return(true); } packAndVersion = PackInfo.Empty; return(false); }
public void AddMatchForPack(PackInfo packInfo, ITemplateMatchInfo matchInfo) { if (!_packsWithMatches.TryGetValue(packInfo, out TemplatePackSearchResult matchesForPack)) { matchesForPack = new TemplatePackSearchResult(packInfo); _packsWithMatches[packInfo] = matchesForPack; } matchesForPack.AddMatch(matchInfo); }
protected virtual TemplateNameSearchResult CreateNameSearchResult(ITemplateInfo candidateTemplateInfo, PackInfo candidatePackInfo) { return(new TemplateNameSearchResult(candidateTemplateInfo, candidatePackInfo)); }
public TemplateNameSearchResult(ITemplateInfo template, PackInfo packInfo) { Template = template; PackInfo = packInfo; }
public TemplatePackSearchResult(PackInfo packInfo) { PackInfo = packInfo; _templateMatches = new List <ITemplateMatchInfo>(); }