/// <summary>
        /// Tries to find the document matching the request, by running the IPublishedContentFinder instances.
        /// </summary>
        /// <exception cref="InvalidOperationException">There is no finder collection.</exception>
        internal void FindPublishedContent(PublishedRequest request)
        {
            const string tracePrefix = "FindPublishedContent: ";

            // look for the document
            // the first successful finder, if any, will set this.PublishedContent, and may also set this.Template
            // some finders may implement caching

            using (_profilingLogger.DebugDuration <PublishedRouter>(
                       $"{tracePrefix}Executing finders...",
                       $"{tracePrefix}Completed executing finders"))
            {
                //iterate but return on first one that finds it
                var found = _contentFinders.Any(finder =>
                {
                    _logger.Debug <PublishedRouter>("Finder {ContentFinderType}", finder.GetType().FullName);
                    return(finder.TryFindContent(request));
                });

                _profilingLogger.Debug <PublishedRouter>(
                    "Found? {Found} Content: {PublishedContentId}, Template: {TemplateAlias}, Domain: {Domain}, Culture: {Culture}, Is404: {Is404}, StatusCode: {StatusCode}",
                    found,
                    request.HasPublishedContent ? request.PublishedContent.Id : "NULL",
                    request.HasTemplate ? request.TemplateAlias : "NULL",
                    request.HasDomain ? request.Domain.ToString() : "NULL",
                    request.Culture?.Name ?? "NULL",
                    request.Is404,
                    request.ResponseStatusCode);
            }

            // indicate that the published content (if any) we have at the moment is the
            // one that was found by the standard finders before anything else took place.
            request.SetIsInitialPublishedContent();
        }
Beispiel #2
0
        /// <summary>
        /// Tries to find the document matching the request, by running the IPublishedContentFinder instances.
        /// </summary>
        /// <exception cref="InvalidOperationException">There is no finder collection.</exception>
        internal void FindPublishedContent(PublishedRequest request)
        {
            const string tracePrefix = "FindPublishedContent: ";

            // look for the document
            // the first successful finder, if any, will set this.PublishedContent, and may also set this.Template
            // some finders may implement caching

            using (_profilingLogger.DebugDuration <PublishedRouter>(
                       $"{tracePrefix}Begin finders",
                       $"{tracePrefix}End finders, {(request.HasPublishedContent ? "a document was found" : "no document was found")}"))
            {
                //iterate but return on first one that finds it
                var found = _contentFinders.Any(finder =>
                {
                    _logger.Debug <PublishedRouter>("Finder {ContentFinderType}", finder.GetType().FullName);
                    return(finder.TryFindContent(request));
                });
            }

            // indicate that the published content (if any) we have at the moment is the
            // one that was found by the standard finders before anything else took place.
            request.SetIsInitialPublishedContent();
        }