/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>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.</remarks> public static void RegisterTypes(IUnityContainer container) { RegisterFacetFactories(container); // config container.RegisterInstance <IReflectorConfiguration>(NakedObjectsRunSettings.ReflectorConfig(), (new ContainerControlledLifetimeManager())); container.RegisterInstance <IEntityObjectStoreConfiguration>(NakedObjectsRunSettings.EntityObjectStoreConfig(), new ContainerControlledLifetimeManager()); // in architecture container.RegisterType <IClassStrategy, DefaultClassStrategy>(new ContainerControlledLifetimeManager()); container.RegisterType <ISpecificationCache, ImmutableInMemorySpecCache>(new ContainerControlledLifetimeManager(), new InjectionConstructor()); container.RegisterType <IReflector, Reflector>(new ContainerControlledLifetimeManager()); container.RegisterType <IMetamodel, Metamodel>(new ContainerControlledLifetimeManager()); container.RegisterType <IMetamodelBuilder, Metamodel>(new ContainerControlledLifetimeManager()); container.RegisterType <IMenuFactory, MenuFactory>(new ContainerControlledLifetimeManager()); container.RegisterType <IPocoAdapterMap, PocoAdapterHashMap>(new PerRequestLifetimeManager(), new InjectionConstructor(10)); container.RegisterType <IIdentityAdapterMap, IdentityAdapterHashMap>(new PerRequestLifetimeManager(), new InjectionConstructor(10)); container.RegisterType <IContainerInjector, DomainObjectContainerInjector>(new PerRequestLifetimeManager()); container.RegisterType <IOidGenerator, EntityOidGenerator>(new PerRequestLifetimeManager()); container.RegisterType <IPersistAlgorithm, EntityPersistAlgorithm>(new PerRequestLifetimeManager()); container.RegisterType <IObjectStore, EntityObjectStore>(new PerRequestLifetimeManager()); container.RegisterType <IIdentityMap, IdentityMapImpl>(new PerRequestLifetimeManager()); container.RegisterType <ITransactionManager, TransactionManager>(new PerRequestLifetimeManager()); container.RegisterType <INakedObjectManager, NakedObjectManager>(new PerRequestLifetimeManager()); container.RegisterType <IObjectPersistor, ObjectPersistor>(new PerRequestLifetimeManager()); container.RegisterType <IServicesManager, ServicesManager>(new PerRequestLifetimeManager()); container.RegisterType <ILifecycleManager, LifeCycleManager>(new PerRequestLifetimeManager()); container.RegisterType <IMetamodelManager, MetamodelManager>(new PerResolveLifetimeManager()); container.RegisterType <ISession, WindowsSession>(new PerRequestLifetimeManager()); container.RegisterType <IMessageBroker, MessageBroker>(new PerRequestLifetimeManager()); container.RegisterType <INakedObjectsFramework, NakedObjectsFramework>(new PerRequestLifetimeManager()); // surface container.RegisterType <IOidStrategy, ExternalOid>(new PerRequestLifetimeManager()); container.RegisterType <INakedObjectsSurface, NakedObjectsSurface>(new PerRequestLifetimeManager()); //Temporary scaffolding container.RegisterType <NakedObjectFactory, NakedObjectFactory>(new PerRequestLifetimeManager()); container.RegisterType <SpecFactory, SpecFactory>(new PerRequestLifetimeManager()); //Externals container.RegisterType <IPrincipal>(new InjectionFactory(c => HttpContext.Current.User)); //DI container.RegisterType <IFrameworkResolver, UnityFrameworkResolver>(new PerRequestLifetimeManager()); // Facet decorators if (NakedObjectsRunSettings.AuditConfig() != null) { container.RegisterType(typeof(IFacetDecorator), typeof(AuditManager), "AuditManager", new ContainerControlledLifetimeManager()); container.RegisterInstance(typeof(IAuditConfiguration), NakedObjectsRunSettings.AuditConfig(), new ContainerControlledLifetimeManager()); } if (NakedObjectsRunSettings.AuthorizationConfig() != null) { container.RegisterType(typeof(IFacetDecorator), typeof(AuthorizationManager), "AuthorizationManager", new ContainerControlledLifetimeManager()); container.RegisterInstance(typeof(IAuthorizationConfiguration), NakedObjectsRunSettings.AuthorizationConfig(), new ContainerControlledLifetimeManager()); } }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>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.</remarks> public static void RegisterTypes(IUnityContainer container) { //Standard configuration StandardUnityConfig.RegisterStandardFacetFactories(container); StandardUnityConfig.RegisterCoreContainerControlledTypes(container); StandardUnityConfig.RegisterCorePerTransactionTypes <PerRequestLifetimeManager>(container); // config container.RegisterInstance <IReflectorConfiguration>(NakedObjectsRunSettings.ReflectorConfig(), (new ContainerControlledLifetimeManager())); container.RegisterInstance <IEntityObjectStoreConfiguration>(NakedObjectsRunSettings.EntityObjectStoreConfig(), new ContainerControlledLifetimeManager()); // surface container.RegisterType <IOidTranslator, OidTranslatorSemiColonSeparatedList>(new PerRequestLifetimeManager()); container.RegisterType <IOidStrategy, EntityOidStrategy>(new PerRequestLifetimeManager()); container.RegisterType <IIdHelper, IdHelper>(new PerRequestLifetimeManager()); container.RegisterType <IFrameworkFacade, FrameworkFacade>(new PerRequestLifetimeManager()); //Externals container.RegisterType <IPrincipal>(new InjectionFactory(c => HttpContext.Current.User)); // Facet decorators if (NakedObjectsRunSettings.AuditConfig() != null) { container.RegisterType(typeof(IFacetDecorator), typeof(AuditManager), "AuditManager", new ContainerControlledLifetimeManager()); container.RegisterInstance(typeof(IAuditConfiguration), NakedObjectsRunSettings.AuditConfig(), new ContainerControlledLifetimeManager()); } if (NakedObjectsRunSettings.AuthorizationConfig() != null) { container.RegisterType(typeof(IFacetDecorator), typeof(AuthorizationManager), "AuthorizationManager", new ContainerControlledLifetimeManager()); container.RegisterInstance(typeof(IAuthorizationConfiguration), NakedObjectsRunSettings.AuthorizationConfig(), new ContainerControlledLifetimeManager()); } }