Merge branch '6.2.0-pubcontent' into 7.0.0-pubcontent
Conflicts: src/Umbraco.Core/Cache/CacheProviderBase.cs src/Umbraco.Core/Cache/HttpRuntimeCacheProvider.cs src/Umbraco.Core/Cache/NullCacheProvider.cs src/Umbraco.Core/Cache/StaticCacheProvider.cs src/Umbraco.Core/Configuration/UmbracoSettings.cs src/Umbraco.Core/CoreBootManager.cs src/Umbraco.Core/Dynamics/PropertyResult.cs src/Umbraco.Core/Models/IPublishedContentProperty.cs src/Umbraco.Core/Models/PublishedItemType.cs src/Umbraco.Core/PropertyEditors/IPropertyEditorValueConverter.cs src/Umbraco.Core/PropertyEditors/PropertyEditorValueConvertersResolver.cs src/Umbraco.Core/PropertyEditors/PropertyValueConvertersResolver.cs src/Umbraco.Core/PublishedContentExtensions.cs src/Umbraco.Core/PublishedContentHelper.cs src/Umbraco.Core/Umbraco.Core.csproj src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs src/Umbraco.Tests/LibraryTests.cs src/Umbraco.Tests/PropertyEditors/PropertyEditorValueConverterTests.cs src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs src/Umbraco.Web/ExamineExtensions.cs src/Umbraco.Web/Models/DynamicPublishedContent.cs src/Umbraco.Web/Models/XmlPublishedContent.cs src/Umbraco.Web/Models/XmlPublishedContentProperty.cs src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs src/Umbraco.Web/PublishedContentExtensions.cs src/Umbraco.Web/Templates/TemplateUtilities.cs src/Umbraco.Web/Umbraco.Web.csproj src/Umbraco.Web/WebBootManager.cs src/Umbraco.Web/umbraco.presentation/macro.cs src/umbraco.MacroEngines/RazorDynamicNode/PropertyResult.cs src/umbraco.MacroEngines/RazorDynamicNode/PublishedContentExtensions.cs
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Examine;
|
||||
using Umbraco.Core.Dynamics;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
|
||||
namespace Umbraco.Web
|
||||
@@ -15,25 +14,39 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
internal static class ExamineExtensions
|
||||
{
|
||||
internal static IEnumerable<IPublishedContent> ConvertSearchResultToPublishedContent(
|
||||
this IEnumerable<SearchResult> results,
|
||||
internal static PublishedContentSet<IPublishedContent> ConvertSearchResultToPublishedContent(this IEnumerable<SearchResult> results,
|
||||
ContextualPublishedCache cache)
|
||||
{
|
||||
//TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent,
|
||||
// however thsi is currently not the case:
|
||||
// however this is currently not the case:
|
||||
// http://examine.codeplex.com/workitem/10350
|
||||
|
||||
var list = new List<IPublishedContent>();
|
||||
var list = new List<IPublishedContent>();
|
||||
var set = new PublishedContentSet<IPublishedContent>(list);
|
||||
|
||||
foreach (var result in results.OrderByDescending(x => x.Score))
|
||||
{
|
||||
var doc = cache.GetById(result.Id);
|
||||
if (doc == null) continue; //skip if this doesn't exist in the cache
|
||||
doc.Properties.Add(
|
||||
new PropertyResult("examineScore", result.Score.ToString(), PropertyResultType.CustomProperty));
|
||||
list.Add(doc);
|
||||
var content = cache.GetById(result.Id);
|
||||
if (content == null) continue; // skip if this doesn't exist in the cache
|
||||
|
||||
// need to extend the content as we're going to add a property to it,
|
||||
// and we should not ever do it to the content we get from the cache,
|
||||
// precisely because it is cached and shared by all requests.
|
||||
|
||||
// but we cannot wrap it because we need to respect the type that was
|
||||
// returned by the cache, in case the cache can create real types.
|
||||
// so we have to ask it to please extend itself.
|
||||
|
||||
list.Add(content);
|
||||
var extend = set.MapContent(content);
|
||||
|
||||
var property = new PropertyResult("examineScore",
|
||||
result.Score,
|
||||
PropertyResultType.CustomProperty);
|
||||
extend.AddProperty(property);
|
||||
}
|
||||
return list;
|
||||
|
||||
return set;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user