Esempio n. 1
0
        /// <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)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();
            //Standard configuration
            try {
                ParallelUnityConfig.RegisterStandardFacetFactories(container);
                ParallelUnityConfig.RegisterCoreContainerControlledTypes(container);
                ParallelUnityConfig.RegisterCorePerTransactionTypes <PerResolveLifetimeManager>(container);

                // config
                container.RegisterInstance <IReflectorConfiguration>(NakedObjectsRunSettings.ReflectorConfig(), (new ContainerControlledLifetimeManager()));
                container.RegisterInstance <IEntityObjectStoreConfiguration>(NakedObjectsRunSettings.EntityObjectStoreConfig(), new ContainerControlledLifetimeManager());

                // frameworkFacade
                container.RegisterType <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>(new PerResolveLifetimeManager());

                container.RegisterType <IOidStrategy, EntityOidStrategy>(new PerResolveLifetimeManager());
                container.RegisterType <IStringHasher, SimpleStringHasher>(new PerResolveLifetimeManager());
                container.RegisterType <IFrameworkFacade, FrameworkFacade>(new PerResolveLifetimeManager());

                //Externals
                container.RegisterType <IPrincipal>(new InjectionFactory(c => HttpContext.Current.User));
            }
            catch (Exception e) {
                Logger.Error($"Error on Unity RegisterTypes : {e.Message}");
                throw;
            }
        }
        /// <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 RegisterParallelTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();
            //Standard configuration

            ParallelUnityConfig.RegisterStandardFacetFactories(container);
            ParallelUnityConfig.RegisterCoreContainerControlledTypes(container);
            ParallelUnityConfig.RegisterCorePerTransactionTypes <HierarchicalLifetimeManager>(container);

            // add custom notnavigable factory

            UnityConfigHelpers.RegisterFacetFactory(typeof(AWNotNavigableFacetFactoryParallel), container, 1000);
            UnityConfigHelpers.RegisterFacetFactory(typeof(AWNotCountedAnnotationFacetFactoryParallel), container, 1001);

            // config
            container.RegisterInstance <IReflectorConfiguration>(NakedObjectsRunSettings.ReflectorConfig(), (new ContainerControlledLifetimeManager()));
            container.RegisterInstance <IEntityObjectStoreConfiguration>(NakedObjectsRunSettings.EntityObjectStoreConfig(), new ContainerControlledLifetimeManager());

            // surface
            container.RegisterType <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>(new HierarchicalLifetimeManager());

            container.RegisterType <IOidStrategy, EntityOidStrategy>(new HierarchicalLifetimeManager());
            container.RegisterType <IStringHasher, SimpleStringHasher>(new HierarchicalLifetimeManager());
            container.RegisterType <IFrameworkFacade, FrameworkFacade>(new HierarchicalLifetimeManager());

            //Externals
            container.RegisterType <IPrincipal>(new InjectionFactory(c => HttpContext.Current.User));
        }
        protected virtual void RegisterParallelTypes(IUnityContainer container)
        {
            //ReflectorConfiguration.NoValidate = true;
            //RegisterFacetFactories(container);

            //container.RegisterType<IMenuFactory, NullMenuFactory>();
            //container.RegisterType<ISpecificationCache, ImmutableInMemorySpecCache>(
            //    new ContainerControlledLifetimeManager(), new InjectionConstructor());
            //container.RegisterType<IClassStrategy, DefaultClassStrategy>();
            //container.RegisterType<IReflector, Reflector>();
            //container.RegisterType<IMetamodel, Metamodel>();
            //container.RegisterType<IMetamodelBuilder, Metamodel>();

            ParallelUnityConfig.RegisterStandardFacetFactories(container);
            ParallelUnityConfig.RegisterCoreContainerControlledTypes(container);
            ParallelUnityConfig.RegisterCorePerTransactionTypes <HierarchicalLifetimeManager>(container);
        }