2016-10-07 14:34:55 +02:00
|
|
|
|
using System;
|
2020-10-27 10:53:01 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2019-02-14 09:15:47 +01:00
|
|
|
|
using Umbraco.Core;
|
2017-05-30 15:46:25 +02:00
|
|
|
|
using Umbraco.Core.Composing;
|
2020-10-27 10:53:01 +00:00
|
|
|
|
using Umbraco.Infrastructure.Composing;
|
2018-10-29 17:27:33 +11:00
|
|
|
|
using Umbraco.Web.Actions;
|
2019-01-29 23:05:59 +11:00
|
|
|
|
using Umbraco.Web.ContentApps;
|
|
|
|
|
|
using Umbraco.Web.Dashboards;
|
2016-10-07 14:34:55 +02:00
|
|
|
|
using Umbraco.Web.Editors;
|
|
|
|
|
|
using Umbraco.Web.HealthCheck;
|
2019-01-31 13:37:47 +00:00
|
|
|
|
using Umbraco.Web.Media.EmbedProviders;
|
2016-10-07 14:34:55 +02:00
|
|
|
|
using Umbraco.Web.Mvc;
|
|
|
|
|
|
using Umbraco.Web.PublishedCache;
|
|
|
|
|
|
using Umbraco.Web.Routing;
|
2019-02-14 11:08:39 +11:00
|
|
|
|
using Umbraco.Web.Search;
|
2019-02-18 11:22:25 +01:00
|
|
|
|
using Umbraco.Web.Sections;
|
2019-01-07 14:11:00 +00:00
|
|
|
|
using Umbraco.Web.Tour;
|
2019-01-22 14:59:32 +00:00
|
|
|
|
using Umbraco.Web.Trees;
|
2019-01-29 23:05:59 +11:00
|
|
|
|
using Current = Umbraco.Web.Composing.Current;
|
2016-10-07 14:34:55 +02:00
|
|
|
|
|
|
|
|
|
|
// the namespace here is intentional - although defined in Umbraco.Web assembly,
|
|
|
|
|
|
// this class should be visible when using Umbraco.Core.Components, alongside
|
|
|
|
|
|
// Umbraco.Core's own CompositionExtensions class
|
|
|
|
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
2019-01-29 23:05:59 +11:00
|
|
|
|
namespace Umbraco.Web
|
2016-10-07 14:34:55 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provides extension methods to the <see cref="Composition"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class WebCompositionExtensions
|
|
|
|
|
|
{
|
2020-10-27 10:53:01 +00:00
|
|
|
|
public static IFactory CreateFactory(this Composition composition)
|
|
|
|
|
|
{
|
|
|
|
|
|
composition.RegisterBuilders();
|
|
|
|
|
|
return ServiceProviderFactoryAdapter.Wrap(composition.Services.BuildServiceProvider());
|
|
|
|
|
|
}
|
2018-11-02 15:33:43 +00:00
|
|
|
|
|
2018-11-29 10:35:16 +01:00
|
|
|
|
#region Uniques
|
2016-10-07 14:34:55 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the content last chance finder.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T">The type of the content last chance finder.</typeparam>
|
|
|
|
|
|
/// <param name="composition">The composition.</param>
|
|
|
|
|
|
public static void SetContentLastChanceFinder<T>(this Composition composition)
|
|
|
|
|
|
where T : IContentLastChanceFinder
|
|
|
|
|
|
{
|
2018-11-29 10:35:16 +01:00
|
|
|
|
composition.RegisterUnique<IContentLastChanceFinder, T>();
|
2016-10-07 14:34:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the content last chance finder.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="composition">The composition.</param>
|
|
|
|
|
|
/// <param name="factory">A function creating a last chance finder.</param>
|
2018-11-28 11:05:41 +01:00
|
|
|
|
public static void SetContentLastChanceFinder(this Composition composition, Func<IFactory, IContentLastChanceFinder> factory)
|
2016-10-07 14:34:55 +02:00
|
|
|
|
{
|
2018-11-29 10:35:16 +01:00
|
|
|
|
composition.RegisterUnique(factory);
|
2016-10-07 14:34:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the content last chance finder.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="composition">The composition.</param>
|
|
|
|
|
|
/// <param name="finder">A last chance finder.</param>
|
|
|
|
|
|
public static void SetContentLastChanceFinder(this Composition composition, IContentLastChanceFinder finder)
|
|
|
|
|
|
{
|
2018-11-29 10:35:16 +01:00
|
|
|
|
composition.RegisterUnique(_ => finder);
|
2016-10-07 14:34:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the site domain helper.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T">The type of the site domain helper.</typeparam>
|
|
|
|
|
|
/// <param name="composition"></param>
|
|
|
|
|
|
public static void SetSiteDomainHelper<T>(this Composition composition)
|
|
|
|
|
|
where T : ISiteDomainHelper
|
|
|
|
|
|
{
|
2018-11-29 10:35:16 +01:00
|
|
|
|
composition.RegisterUnique<ISiteDomainHelper, T>();
|
2016-10-07 14:34:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the site domain helper.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="composition">The composition.</param>
|
|
|
|
|
|
/// <param name="factory">A function creating a helper.</param>
|
2018-11-28 11:05:41 +01:00
|
|
|
|
public static void SetSiteDomainHelper(this Composition composition, Func<IFactory, ISiteDomainHelper> factory)
|
2016-10-07 14:34:55 +02:00
|
|
|
|
{
|
2018-11-29 10:35:16 +01:00
|
|
|
|
composition.RegisterUnique(factory);
|
2016-10-07 14:34:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the site domain helper.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="composition">The composition.</param>
|
|
|
|
|
|
/// <param name="helper">A helper.</param>
|
|
|
|
|
|
public static void SetSiteDomainHelper(this Composition composition, ISiteDomainHelper helper)
|
|
|
|
|
|
{
|
2018-11-29 10:35:16 +01:00
|
|
|
|
composition.RegisterUnique(_ => helper);
|
2016-10-07 14:34:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|