From 4cd0544c65d2a4853de519617694d7e77e535be2 Mon Sep 17 00:00:00 2001 From: Erik-Jan Westendorp Date: Fri, 26 Nov 2021 10:18:45 +0100 Subject: [PATCH] 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 --- .../UmbracoBuilder.CollectionBuilders.cs | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs new file mode 100644 index 0000000000..8b6e6b78d8 --- /dev/null +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs @@ -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 +{ + /// + /// Contains extensions methods for used for registering content apps. + /// + public static partial class UmbracoBuilderExtensions + { + /// + /// Register a component. + /// + /// The type of the component. + /// The builder. + public static IUmbracoBuilder AddComponent(this IUmbracoBuilder builder) + where T : class, IComponent + { + builder.Components().Append(); + return builder; + } + + /// + /// Register a content app. + /// + /// The type of the content app. + /// The builder. + public static IUmbracoBuilder AddContentApp(this IUmbracoBuilder builder) + where T : class, IContentAppFactory + { + builder.ContentApps().Append(); + return builder; + } + + /// + /// Register a content finder. + /// + /// The type of the content finder. + /// The builder. + public static IUmbracoBuilder AddContentFinder(this IUmbracoBuilder builder) + where T : class, IContentFinder + { + builder.ContentFinders().Append(); + return builder; + } + + /// + /// Register a dashboard. + /// + /// The type of the dashboard. + /// The builder. + public static IUmbracoBuilder AddDashboard(this IUmbracoBuilder builder) + where T : class, IDashboard + { + builder.Dashboards().Add(); + return builder; + } + + /// + /// Register a media url provider. + /// + /// The type of the media url provider. + /// The builder. + public static IUmbracoBuilder AddMediaUrlProvider(this IUmbracoBuilder builder) + where T : class, IMediaUrlProvider + { + builder.MediaUrlProviders().Append(); + return builder; + } + + /// + /// Register a embed provider. + /// + /// The type of the embed provider. + /// The builder. + public static IUmbracoBuilder AddOEmbedProvider(this IUmbracoBuilder builder) + where T : class, IEmbedProvider + { + builder.OEmbedProviders().Append(); + return builder; + } + + /// + /// Register a section. + /// + /// The type of the section. + /// The builder. + public static IUmbracoBuilder AddSection(this IUmbracoBuilder builder) + where T : class, ISection + { + builder.Sections().Append(); + return builder; + } + + /// + /// Register a url provider. + /// + /// The type of the url provider. + /// The Builder. + public static IUmbracoBuilder AddUrlProvider(this IUmbracoBuilder builder) + where T : class, IUrlProvider + { + builder.UrlProviders().Append(); + return builder; + } + } +}