using System.Reflection;
using System.Web.Http.Controllers;
using System.Web.Mvc;
using LightInject;
using Umbraco.Core;
namespace Umbraco.Web
{
internal static class LightInjectExtensions
{
///
/// Registers all IControllers using the PluginManager for scanning and caching found instances for the calling assembly
///
///
///
public static void RegisterMvcControllers(this IServiceRegistry container, PluginManager pluginManager)
{
var types = pluginManager.ResolveTypes(specificAssemblies: new[] { Assembly.GetCallingAssembly() });
foreach (var type in types)
{
container.Register(type, new PerRequestLifeTime());
}
}
///
/// Registers all IHttpController using the PluginManager for scanning and caching found instances for the calling assembly
///
///
///
public static void RegisterApiControllers(this IServiceRegistry container, PluginManager pluginManager)
{
var types = pluginManager.ResolveTypes(specificAssemblies: new[] { Assembly.GetCallingAssembly() });
foreach (var type in types)
{
container.Register(type, new PerRequestLifeTime());
}
}
}
}