Ability to add/remove/replace an ISearchableTree
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.Search
|
||||
{
|
||||
public interface ISearchableTree
|
||||
{
|
||||
/// <summary>
|
||||
/// The alias of the tree that the <see cref="ISearchableTree"/> belongs to
|
||||
/// </summary>
|
||||
string TreeAlias { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for results based on the entity type
|
||||
/// </summary>
|
||||
|
||||
@@ -40,21 +40,19 @@ namespace Umbraco.Web.Search
|
||||
var appTrees = _treeService.GetAll().ToArray();
|
||||
_resolved = new SearchableTreeCollection();
|
||||
var searchableTrees = Values.ToArray();
|
||||
foreach (var instanceType in InstanceTypes)
|
||||
foreach (var searchableTree in searchableTrees)
|
||||
{
|
||||
if (TypeHelper.IsTypeAssignableFrom<ISearchableTree>(instanceType))
|
||||
var found = appTrees.FirstOrDefault(x => x.Alias == searchableTree.TreeAlias);
|
||||
if (found != null)
|
||||
{
|
||||
var found = appTrees.FirstOrDefault(x => x.GetRuntimeType() == instanceType);
|
||||
if (found != null)
|
||||
{
|
||||
_resolved.Add(new SearchableApplicationTree(found.ApplicationAlias, found.Alias, searchableTrees.First(x => x.GetType() == instanceType)));
|
||||
}
|
||||
_resolved.Add(new SearchableApplicationTree(found.ApplicationAlias, found.Alias, searchableTree));
|
||||
}
|
||||
}
|
||||
return _resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user