using System;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.Actions;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Dashboards;
using Umbraco.Web.Editors;
using Umbraco.Web.HealthCheck;
using Umbraco.Web.Media.EmbedProviders;
using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Search;
using Umbraco.Web.Sections;
using Umbraco.Web.Tour;
using Umbraco.Web.Trees;
using Current = Umbraco.Web.Composing.Current;
// 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
namespace Umbraco.Web
{
///
/// Provides extension methods to the class.
///
public static class WebCompositionExtensions
{
[Obsolete("This extension method exists only to ease migration, please refactor")]
public static IServiceProvider CreateServiceProvider(this Composition composition)
{
composition.RegisterBuilders();
return composition.Services.BuildServiceProvider();
}
#region Uniques
///
/// Sets the content last chance finder.
///
/// The type of the content last chance finder.
/// The composition.
public static void SetContentLastChanceFinder(this Composition composition)
where T : class, IContentLastChanceFinder
{
composition.Services.AddUnique();
}
///
/// Sets the content last chance finder.
///
/// The composition.
/// A function creating a last chance finder.
public static void SetContentLastChanceFinder(this Composition composition, Func factory)
{
composition.Services.AddUnique(factory);
}
///
/// Sets the content last chance finder.
///
/// The composition.
/// A last chance finder.
public static void SetContentLastChanceFinder(this Composition composition, IContentLastChanceFinder finder)
{
composition.Services.AddUnique(_ => finder);
}
///
/// Sets the site domain helper.
///
/// The type of the site domain helper.
///
public static void SetSiteDomainHelper(this Composition composition)
where T : class, ISiteDomainHelper
{
composition.Services.AddUnique();
}
///
/// Sets the site domain helper.
///
/// The composition.
/// A function creating a helper.
public static void SetSiteDomainHelper(this Composition composition, Func factory)
{
composition.Services.AddUnique(factory);
}
///
/// Sets the site domain helper.
///
/// The composition.
/// A helper.
public static void SetSiteDomainHelper(this Composition composition, ISiteDomainHelper helper)
{
composition.Services.AddUnique(_ => helper);
}
#endregion
}
}