public virtual async Task <bool> IsMatch(SegmentContext segmentContext) { while (true) { var segment = segmentContext.GetNextValue(segmentContext.RemainingPath); var segmentValue = segment.Next; var document = await _sanityClient.GetBySlug <ISanityDocument>(segmentValue, segmentContext.Language); if (document == null) { var isValidRoute = segmentContext.RoutedDocument != null && segmentContext.RemainingPath.IndexOf('/') == -1; if (!isValidRoute) { segmentContext.RoutedDocumentId = Guid.Empty; segmentContext.RoutedDocument = null; } return(isValidRoute); } if (!segmentContext.ConsumedDocuments.Contains(document.Id)) { segmentContext.ConsumedDocuments.Add(document.Id); } if (!IsValidParent(segmentContext, document)) { segmentContext.RoutedDocument = null; return(false); } segmentContext.RoutedDocument = document; segmentContext.RoutedDocumentId = document.Id; segmentContext.RemainingPath = segment.Remaining; if (!string.IsNullOrEmpty(segmentContext.RemainingPath)) { continue; } return(true); } }
public async Task <T> GetBySlug <T>(string slug, CultureInfo language) where T : ISanityDocument { return(await _cacheHandler.GetCachedOrLoad(slug, language, () => _inner.GetBySlug <T>(slug, language))); }