using Api.Security;
using BusinessLogic.Interfaces.Security;
using DataAccess.Persistence;
using System;
using Unity;
using Unity.Lifetime;
using Unity.log4net;
namespace Api
{
///
/// Specifies the Unity configuration for the main container.
///
public static class UnityConfig
{
#region Unity Container
private static Lazy container =
new Lazy(() =>
{
var container = new UnityContainer();
RegisterTypes(container);
return container;
});
///
/// Configured Unity Container.
///
public static IUnityContainer Container => container.Value;
#endregion
///
/// Registers the type mappings with the Unity container.
///
/// The unity container to configure.
///
/// There is no need to register concrete types such as controllers or
/// API controllers (unless you want to change the defaults), as Unity
/// allows resolving a concrete type even if it was not previously
/// registered.
///
public static void RegisterTypes(IUnityContainer container)
{
// NOTE: To load from web.config uncomment the line below.
// Make sure to add a Unity.Configuration to the using statements.
// container.LoadConfiguration();
// container.RegisterType();
container.AddExtension(new Diagnostic());
container
.RegisterType()
.RegisterType(new PerThreadLifetimeManager());
BusinessLogic.UnityConfig.RegisterComponents(container);
DataAccess.UnityConfig.RegisterComponents(container);
log4net.Config.XmlConfigurator.Configure();
container.AddNewExtension();
}
}
}