Add new UmbracoBuiilder extension methods to discover and set an IUmbracoTreeSearcherFields (#12751)

This commit is contained in:
Warren Buckley
2022-08-04 10:21:36 +01:00
committed by GitHub
parent 99dfeddf97
commit faf4320eb5

View File

@@ -1,5 +1,6 @@
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Infrastructure.Examine;
namespace Umbraco.Extensions;
@@ -84,5 +85,41 @@ public static class WebsiteUmbracoBuilderExtensions
return builder;
}
/// <summary>
/// Sets the UmbracoTreeSearcherFields to change fields that can be searched in the backoffice.
/// </summary>
/// <typeparam name="T">The type of the Umbraco tree searcher fields.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder SetTreeSearcherFields<T>(this IUmbracoBuilder builder)
where T : class, IUmbracoTreeSearcherFields
{
builder.Services.AddUnique<IUmbracoTreeSearcherFields, T>();
return builder;
}
/// <summary>
/// Sets the UmbracoTreeSearcherFields to change fields that can be searched in the backoffice.
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="factory">A function creating a TreeSearcherFields</param>
public static IUmbracoBuilder SetTreeSearcherFields(
this IUmbracoBuilder builder,
Func<IServiceProvider, IUmbracoTreeSearcherFields> factory)
{
builder.Services.AddUnique(factory);
return builder;
}
/// <summary>
/// Sets the UmbracoTreeSearcherFields to change fields that can be searched in the backoffice.
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="treeSearcherFields">An UmbracoTreeSearcherFields.</param>
public static IUmbracoBuilder SetTreeSearcherFields(this IUmbracoBuilder builder, IUmbracoTreeSearcherFields treeSearcherFields)
{
builder.Services.AddUnique(treeSearcherFields);
return builder;
}
#endregion
}