using BusinessLogic.Interfaces.Security; using BusinessLogic.Security; using DataAccess.Persistence; using PaymentPortal.Controllers; using PaymentPortal.Security; using System; using System.Web.Mvc; using Unity; using Unity.AspNet.Mvc; using Unity.log4net; namespace PaymentPortal { 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.RegisterType(new PerRequestLifetimeManager()); container.RegisterType(new PerRequestLifetimeManager()); container.RegisterType(new PerRequestLifetimeManager()); RegisterControllerDependencies(container); BusinessLogic.UnityConfig.RegisterComponents(container); DataAccess.UnityConfig.RegisterComponents(container); log4net.Config.XmlConfigurator.Configure(); container.AddNewExtension(); DependencyResolver.SetResolver(new UnityDependencyResolver(container)); } private static void RegisterControllerDependencies(IUnityContainer container) { container.RegisterType(); } } }