Beispiel #1
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <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 AddNakedObjects(this IServiceCollection services, IConfiguration configuration)
        {
            // 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

            ParallelConfig.RegisterStandardFacetFactories(services);
            ParallelConfig.RegisterCoreSingletonTypes(services);
            ParallelConfig.RegisterCoreScopedTypes(services);

            // add custom factories

            ConfigHelpers.RegisterFacetFactory(typeof(AWNotNavigableFacetFactoryParallel), services, 1000);
            ConfigHelpers.RegisterFacetFactory(typeof(AWNotCountedAnnotationFacetFactoryParallel), services, 1001);

            // config
            services.AddSingleton <IReflectorConfiguration>(p => NakedObjectsRunSettings.ReflectorConfig());
            services.AddSingleton <IEntityObjectStoreConfiguration>(p => NakedObjectsRunSettings.EntityObjectStoreConfig(configuration));

            // frameworkFacade
            services.AddTransient <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>();

            services.AddTransient <IOidStrategy, EntityOidStrategy>();
            services.AddTransient <IStringHasher, InvariantStringHasher>();
            services.AddTransient <IFrameworkFacade, FrameworkFacade>();

            //Externals
            services.AddScoped <IPrincipal>(p => p.GetService <IHttpContextAccessor>().HttpContext.User);
        }
        /// <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

            StandardUnityConfig.RegisterStandardFacetFactories(container);
            StandardUnityConfig.RegisterCoreContainerControlledTypes(container);
            StandardUnityConfig.RegisterCorePerTransactionTypes <PerResolveLifetimeManager>(container);

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

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

            container.RegisterType <IOidStrategy, EntityOidStrategy>(new PerResolveLifetimeManager());
            container.RegisterType <IIdHelper, IdHelper>(new PerResolveLifetimeManager());

            container.RegisterType <IFrameworkFacade, FrameworkFacade>(new PerResolveLifetimeManager());

            //Externals
            container.RegisterType <IPrincipal>(new InjectionFactory(c => HttpContext.Current.User));
        }
        /// <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

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

            // add custom notnavigable factory

            UnityConfigHelpers.RegisterFacetFactory(typeof(AWNotNavigableFacetFactory), container, 1000);
            UnityConfigHelpers.RegisterFacetFactory(typeof(AWNotCountedAnnotationFacetFactory), 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));
        }
        /// <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();

            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 PerResolveLifetimeManager(), new InjectionConstructor(10));
            container.RegisterType <IIdentityAdapterMap, IdentityAdapterHashMap>(new PerResolveLifetimeManager(), new InjectionConstructor(10));
            container.RegisterType <IContainerInjector, DomainObjectContainerInjector>(new PerResolveLifetimeManager());
            container.RegisterType <IOidGenerator, EntityOidGenerator>(new PerResolveLifetimeManager());
            container.RegisterType <IPersistAlgorithm, EntityPersistAlgorithm>(new PerResolveLifetimeManager());
            container.RegisterType <IObjectStore, EntityObjectStore>(new PerResolveLifetimeManager());
            container.RegisterType <IIdentityMap, IdentityMapImpl>(new PerResolveLifetimeManager());
            container.RegisterType <ITransactionManager, TransactionManager>(new PerResolveLifetimeManager());
            container.RegisterType <INakedObjectManager, NakedObjectManager>(new PerResolveLifetimeManager());
            container.RegisterType <IObjectPersistor, ObjectPersistor>(new PerResolveLifetimeManager());
            container.RegisterType <IServicesManager, ServicesManager>(new PerResolveLifetimeManager());
            container.RegisterType <ILifecycleManager, LifeCycleManager>(new PerResolveLifetimeManager());
            container.RegisterType <IMetamodelManager, MetamodelManager>(new PerResolveLifetimeManager());
            container.RegisterType <ISession, WindowsSession>(new PerResolveLifetimeManager());
            container.RegisterType <IMessageBroker, MessageBroker>(new PerResolveLifetimeManager());
            container.RegisterType <INakedObjectsFramework, NakedObjectsFramework>(new PerResolveLifetimeManager());


            // surface
            container.RegisterType <IOidStrategy, ExternalOid>(new PerResolveLifetimeManager());
            container.RegisterType <INakedObjectsSurface, NakedObjectsSurface>(new PerResolveLifetimeManager());

            //Temporary scaffolding
            container.RegisterType <NakedObjectFactory, NakedObjectFactory>(new PerResolveLifetimeManager());
            container.RegisterType <SpecFactory, SpecFactory>(new PerResolveLifetimeManager());

            //Externals
            container.RegisterType <IPrincipal>(new InjectionFactory(c => HttpContext.Current.User));

            //DI
            container.RegisterType <IFrameworkResolver, UnityFrameworkResolver>(new PerResolveLifetimeManager());
        }
Beispiel #5
0
        public static void AddNakedObjects(this IServiceCollection services, IConfiguration configuration)
        {
            ParallelConfig.RegisterStandardFacetFactories(services);
            ParallelConfig.RegisterCoreSingletonTypes(services);
            ParallelConfig.RegisterCoreScopedTypes(services);

            // config
            services.AddSingleton <IReflectorConfiguration>(p => NakedObjectsRunSettings.ReflectorConfig());
            services.AddSingleton <IEntityObjectStoreConfiguration>(p => NakedObjectsRunSettings.EntityObjectStoreConfig(configuration));

            // frameworkFacade
            services.AddTransient <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>();

            services.AddTransient <IOidStrategy, EntityOidStrategy>();
            services.AddTransient <IStringHasher, InvariantStringHasher>();
            services.AddTransient <IFrameworkFacade, FrameworkFacade>();


            //Externals
            services.AddScoped <IPrincipal>(p => p.GetService <IHttpContextAccessor>().HttpContext.User);
        }