Create an extension methods to easily append to CollectionBuilders (#11691)

* Create UmbracoBuilder.ContentApps.cs

Add an extension method to register content apps to make it possible to register content apps in the startup.cs class.

* Create UmbracoBuilder.CollectionsBuilders

* White space

* Rename OEmbedProvider to EmbedProvider

* Rename EmbedProvider to OEmbedProvider
This commit is contained in:
Erik-Jan Westendorp
2021-11-26 10:18:45 +01:00
committed by GitHub
parent 004d3410e9
commit 4cd0544c65

View File

@@ -0,0 +1,111 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.Media;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Sections;
namespace Umbraco.Cms.Core.DependencyInjection
{
/// <summary>
/// Contains extensions methods for <see cref="IUmbracoBuilder"/> used for registering content apps.
/// </summary>
public static partial class UmbracoBuilderExtensions
{
/// <summary>
/// Register a component.
/// </summary>
/// <typeparam name="T">The type of the component.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddComponent<T>(this IUmbracoBuilder builder)
where T : class, IComponent
{
builder.Components().Append<T>();
return builder;
}
/// <summary>
/// Register a content app.
/// </summary>
/// <typeparam name="T">The type of the content app.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddContentApp<T>(this IUmbracoBuilder builder)
where T : class, IContentAppFactory
{
builder.ContentApps().Append<T>();
return builder;
}
/// <summary>
/// Register a content finder.
/// </summary>
/// <typeparam name="T">The type of the content finder.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddContentFinder<T>(this IUmbracoBuilder builder)
where T : class, IContentFinder
{
builder.ContentFinders().Append<T>();
return builder;
}
/// <summary>
/// Register a dashboard.
/// </summary>
/// <typeparam name="T">The type of the dashboard.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddDashboard<T>(this IUmbracoBuilder builder)
where T : class, IDashboard
{
builder.Dashboards().Add<T>();
return builder;
}
/// <summary>
/// Register a media url provider.
/// </summary>
/// <typeparam name="T">The type of the media url provider.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddMediaUrlProvider<T>(this IUmbracoBuilder builder)
where T : class, IMediaUrlProvider
{
builder.MediaUrlProviders().Append<T>();
return builder;
}
/// <summary>
/// Register a embed provider.
/// </summary>
/// <typeparam name="T">The type of the embed provider.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddOEmbedProvider<T>(this IUmbracoBuilder builder)
where T : class, IEmbedProvider
{
builder.OEmbedProviders().Append<T>();
return builder;
}
/// <summary>
/// Register a section.
/// </summary>
/// <typeparam name="T">The type of the section.</typeparam>
/// <param name="builder">The builder.</param>
public static IUmbracoBuilder AddSection<T>(this IUmbracoBuilder builder)
where T : class, ISection
{
builder.Sections().Append<T>();
return builder;
}
/// <summary>
/// Register a url provider.
/// </summary>
/// <typeparam name="T">The type of the url provider.</typeparam>
/// <param name="builder">The Builder.</param>
public static IUmbracoBuilder AddUrlProvider<T>(this IUmbracoBuilder builder)
where T : class, IUrlProvider
{
builder.UrlProviders().Append<T>();
return builder;
}
}
}