Ability to add/remove/replace an ISearchableTree

This commit is contained in:
Shannon
2017-05-31 22:52:16 +02:00
parent 106a06be2a
commit 618c50f9da
2 changed files with 12 additions and 8 deletions

View File

@@ -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>

View File

@@ -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;
}
}
}
}
}