Changes the result of SearchableTreeResolver to be readonly
This commit is contained in:
@@ -120,21 +120,21 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
foreach (var searchableTree in searchableTrees)
|
||||
{
|
||||
if (allowedSections.Contains(searchableTree.AppAlias))
|
||||
if (allowedSections.Contains(searchableTree.Value.AppAlias))
|
||||
{
|
||||
var tree = Services.ApplicationTreeService.GetByAlias(searchableTree.TreeAlias);
|
||||
var tree = Services.ApplicationTreeService.GetByAlias(searchableTree.Key);
|
||||
if (tree == null) continue; //shouldn't occur
|
||||
|
||||
var searchableTreeAttribute = searchableTree.SearchableTree.GetType().GetCustomAttribute<SearchableTreeAttribute>(false);
|
||||
var searchableTreeAttribute = searchableTree.Value.SearchableTree.GetType().GetCustomAttribute<SearchableTreeAttribute>(false);
|
||||
var treeAttribute = tree.GetTreeAttribute();
|
||||
|
||||
long total;
|
||||
|
||||
result[treeAttribute.GetRootNodeDisplayName(Services.TextService)] = new TreeSearchResult
|
||||
{
|
||||
Results = searchableTree.SearchableTree.Search(query, 200, 0, out total),
|
||||
TreeAlias = searchableTree.TreeAlias,
|
||||
AppAlias = searchableTree.AppAlias,
|
||||
Results = searchableTree.Value.SearchableTree.Search(query, 200, 0, out total),
|
||||
TreeAlias = searchableTree.Key,
|
||||
AppAlias = searchableTree.Value.AppAlias,
|
||||
JsFormatterService = searchableTreeAttribute == null ? "" : searchableTreeAttribute.ServiceName,
|
||||
JsFormatterMethod = searchableTreeAttribute == null ? "" : searchableTreeAttribute.MethodName
|
||||
};
|
||||
|
||||
@@ -10,13 +10,6 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// </summary>
|
||||
[DataMember(Name = "score")]
|
||||
public float Score { get; set; }
|
||||
|
||||
//TODO: Enable this!
|
||||
///// <summary>
|
||||
///// A caption for the search result
|
||||
///// </summary>
|
||||
//[DataMember(Name = "caption")]
|
||||
//public string Caption { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Umbraco.Web.Search
|
||||
{
|
||||
public class SearchableTreeCollection : KeyedCollection<string, SearchableApplicationTree>
|
||||
internal class SearchableTreeCollection : KeyedCollection<string, SearchableApplicationTree>
|
||||
{
|
||||
protected override string GetKeyForItem(SearchableApplicationTree item)
|
||||
{
|
||||
return item.TreeAlias;
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, SearchableApplicationTree> AsReadOnlyDictionary()
|
||||
{
|
||||
return new ReadOnlyDictionary<string, SearchableApplicationTree>(Dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,13 +23,13 @@ namespace Umbraco.Web.Search
|
||||
_treeService = treeService;
|
||||
}
|
||||
|
||||
private SearchableTreeCollection _resolved;
|
||||
private IReadOnlyDictionary<string, SearchableApplicationTree> _resolved;
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the a dictionary of tree alias with it's affiliated <see cref="ISearchableTree"/>
|
||||
/// </summary>
|
||||
public SearchableTreeCollection SearchableTrees
|
||||
public IReadOnlyDictionary<string, SearchableApplicationTree> SearchableTrees
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -38,16 +38,17 @@ namespace Umbraco.Web.Search
|
||||
lock (Locker)
|
||||
{
|
||||
var appTrees = _treeService.GetAll().ToArray();
|
||||
_resolved = new SearchableTreeCollection();
|
||||
var collection = new SearchableTreeCollection();
|
||||
var searchableTrees = Values.ToArray();
|
||||
foreach (var searchableTree in searchableTrees)
|
||||
{
|
||||
var found = appTrees.FirstOrDefault(x => x.Alias == searchableTree.TreeAlias);
|
||||
if (found != null)
|
||||
{
|
||||
_resolved.Add(new SearchableApplicationTree(found.ApplicationAlias, found.Alias, searchableTree));
|
||||
collection.Add(new SearchableApplicationTree(found.ApplicationAlias, found.Alias, searchableTree));
|
||||
}
|
||||
}
|
||||
_resolved = collection.AsReadOnlyDictionary();
|
||||
return _resolved;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user