Files
Umbraco-CMS/src/Umbraco.Web/ExamineExtensions.cs
Shannon Deminick 1566b16f0f Migrated most of the functionality from RazorLibraryCore to UmbracoHelper and updated RazorLibraryCore to call
the methods in UmbracoHelper so we only have to maintain one set of code. Didn't port over the Wrap methods because
I need feedback on these as to what they do/are supposed to do.
Added the Media methods to UmbracoHelper using the media store stuff.
2012-09-14 09:09:23 +07:00

36 lines
993 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Examine;
using Umbraco.Core.Dynamics;
namespace Umbraco.Web
{
/// <summary>
/// Extension methods for Examine
/// </summary>
internal static class ExamineExtensions
{
internal static DynamicDocumentList ConvertSearchResultToDynamicDocument(
this IEnumerable<SearchResult> results,
IPublishedStore store)
{
var list = new DynamicDocumentList();
var xd = new XmlDocument();
foreach (var result in results.OrderByDescending(x => x.Score))
{
var doc = store.GetDocumentById(
UmbracoContext.Current,
result.Id);
if (doc == null) continue; //skip if this doesn't exist in the cache
doc.Properties.Add(
new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty));
var dynamicDoc = new DynamicDocument(doc);
list.Add(dynamicDoc);
}
return list;
}
}
}