private static bool TryReadTemplateList(JObject cacheObject, string cacheVersion, out IReadOnlyList <ITemplateInfo> templateList) { try { // This is lifted from TemplateCache.ParseCacheContent - almost identical if (cacheObject.TryGetValue(nameof(TemplateDiscoveryMetadata.TemplateCache), StringComparison.OrdinalIgnoreCase, out JToken templateInfoToken)) { List <ITemplateInfo> buildingTemplateList = new List <ITemplateInfo>(); if (templateInfoToken is JArray arr) { foreach (JToken entry in arr) { if (entry != null && entry.Type == JTokenType.Object) { buildingTemplateList.Add(TemplateInfo.FromJObject((JObject)entry, cacheVersion)); } } } templateList = buildingTemplateList; return(true); } templateList = null; return(false); } catch { templateList = null; return(false); } }