public void NamedCloneWithRegistrationTest()
		{
			InjectionKernelManager manager = new InjectionKernelManager(null,
				DependencyInjectionContainer.CompareExportStrategies,
				new BlackList());
			InjectionKernel kernel = new InjectionKernel(manager,
				null,
				null,
				"RootScope",
				DependencyInjectionContainer.CompareExportStrategies);

			manager.SetRootScope(kernel);

			manager.Configure("TestKernel", c => c.Export<BasicService>().As<IBasicService>());

			IInjectionScope injectionScope =
				manager.CreateNewKernel(kernel,
					"TestKernel",
					c => c.Export<ImportConstructorService>().As<IImportConstructorService>(),
					null,
					null);

			IImportConstructorService importService = injectionScope.Locate<IImportConstructorService>();

			Assert.NotNull(importService);
		}
        public void CloneScopeInfoTest()
        {
            InjectionKernelManager manager = new InjectionKernelManager(null,
                DependencyInjectionContainer.CompareExportStrategies,
                new BlackList());
            InjectionKernel injectionKernel = new InjectionKernel(manager,
                new FauxInjectionScope(),
                null,
                null,
                DependencyInjectionContainer.CompareExportStrategies);

            IInjectionScope cloneScope = null;
            IInjectionScope requestScope = null;

            injectionKernel.Configure(
                ioc =>
                {
                    ioc.ExportInstance((scope, context) =>
                                   {
                                       Assert.True(ReferenceEquals(requestScope, context.RequestingScope),
                                           "Requesting scope incorrect");

                                       return new BasicService();
                                   }).As<IBasicService>();

                    ioc.Export<ImportConstructorService>().As<IImportConstructorService>();
                });

            cloneScope = injectionKernel.Clone(null, null, null);
            requestScope = cloneScope.CreateChildScope();

            IImportConstructorService importPropertyService = requestScope.Locate<IImportConstructorService>();

            Assert.NotNull(importPropertyService);
        }
        public void ImportGenericList()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export(typeof(GenericService<>)).As(typeof(IGenericService<>));
                                          c.Export(typeof(ConstrainedService<>)).As(typeof(IGenericService<>));
                                      });

            IEnumerable<IGenericService<int>> services = injectionKernel.LocateAll<IGenericService<int>>();

            Assert.NotNull(services);
            Assert.Equal(1, services.Count());

            IEnumerable<IGenericService<IBasicService>> basicServices =
                injectionKernel.LocateAll<IGenericService<IBasicService>>();

            Assert.NotNull(basicServices);
            Assert.Equal(2, basicServices.Count());
        }
示例#4
0
        /// <summary>
        /// Allows you to configure a base kernel of a particular name
        /// </summary>
        /// <param name="kernelName">name of the kernel being configured</param>
        /// <param name="registrationDelegate">registration delegate to call configure with</param>
        public void Configure(string kernelName, ExportRegistrationDelegate registrationDelegate)
        {
            InjectionKernel kernel;

            if (!kernels.TryGetValue(kernelName, out kernel))
            {
                if (rootScope == null)
                {
                    throw new Exception("SetRootScope must be called before configuring any named kernels");
                }

                kernel = new InjectionKernel(this, rootScope, null, kernelName, comparer);

                lock (kernelsLock)
                {
                    Dictionary<string, InjectionKernel> newKernels = new Dictionary<string, InjectionKernel>(kernels);

                    newKernels[kernelName] = kernel;

                    kernels = newKernels;
                }
            }

            kernel.Configure(registrationDelegate);
        }
        public void BasicGenericTest()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export(typeof(GenericService<>)).As(typeof(IGenericService<>)));

            IGenericService<int> service = injectionKernel.Locate<IGenericService<int>>();

            Assert.NotNull(service);
        }
        public void AndConditionTest()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<ImportPropertyService>()
                                              .As<IImportPropertyService>()
                                              .ImportProperty(o => o.BasicService);

                                          c.Export<ImportMethodService>()
                                              .As<IImportMethodService>()
                                              .ImportMethod(o => o.ImportMethod(null));

                                          c.Export<BasicService>()
                                              .As<IBasicService>()
                                              .AndCondition(
                                                  new WhenCondition(
                                                      (x, y, z) => y.TargetInfo.InjectionType == typeof(ImportPropertyService)));

                                          c.Export<FauxBasicService>()
                                              .As<IBasicService>()
                                              .AndCondition(
                                                  new WhenCondition(
                                                      (x, y, z) => y.TargetInfo.InjectionType == typeof(ImportMethodService)));
                                      });

            IImportPropertyService propertyService = injectionKernel.Locate<IImportPropertyService>();

            Assert.NotNull(propertyService);
            Assert.NotNull(propertyService.BasicService);
            Assert.IsType(typeof(BasicService), propertyService.BasicService);

            IImportMethodService methodService = injectionKernel.Locate<IImportMethodService>();

            Assert.NotNull(methodService);
            Assert.NotNull(methodService.BasicService);
            Assert.IsType(typeof(FauxBasicService), methodService.BasicService);
        }
        public void ComplexTest()
        {
            InjectionKernelManager manager = new InjectionKernelManager(null,
                DependencyInjectionContainer.CompareExportStrategies,
                new BlackList());
            InjectionKernel injectionKernel = new InjectionKernel(manager,
                null,
                null,
                "RootScope",
                DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.ExportAssembly(GetType().Assembly));

            IComplexService complexService =
                injectionKernel.Locate<IComplexService>();

            complexService.Validate();
        }
        public void ImportCostructorTest()
        {
            InjectionKernelManager manager = new InjectionKernelManager(null,
                DependencyInjectionContainer.CompareExportStrategies,
                new BlackList());
            InjectionKernel injectionKernel = new InjectionKernel(manager,
                null,
                null,
                "RootScope",
                DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.ExportAssembly(GetType().Assembly));

            IAttributeImportConstructorService basicService =
                injectionKernel.Locate<IAttributeImportConstructorService>();

            Assert.NotNull(basicService);
        }
		public void NonNamedCloneTest()
		{
			InjectionKernelManager manager = new InjectionKernelManager(null,
				DependencyInjectionContainer.CompareExportStrategies,
				new BlackList());
			InjectionKernel kernel = new InjectionKernel(manager,
				null,
				null,
				"RootScope",
				DependencyInjectionContainer.CompareExportStrategies);

			kernel.Configure(c => c.Export<BasicService>().As<IBasicService>());

			IInjectionScope injectionScope = manager.CreateNewKernel(kernel, null, null, null, null);

			IBasicService basicService = injectionScope.Locate<IBasicService>();

			Assert.NotNull(basicService);
		}
示例#10
0
		public void AttributedOpenGenericTest()
		{
			InjectionKernelManager manager = new InjectionKernelManager(null,
				DependencyInjectionContainer.CompareExportStrategies,
				new BlackList());

			InjectionKernel injectionKernel = new InjectionKernel(manager,
				null,
				null,
				"RootScope",
				DependencyInjectionContainer.CompareExportStrategies);

			injectionKernel.Configure(c => c.ExportAssembly(GetType().Assembly));

			IAttributedOpenGenericTransient<int> transient =
				injectionKernel.Locate<IAttributedOpenGenericTransient<int>>();

			Assert.NotNull(transient);
		}
示例#11
0
        public void ActivationMethodTest()
        {
            InjectionKernelManager manager = new InjectionKernelManager(null,
                DependencyInjectionContainer.CompareExportStrategies,
                new BlackList());
            InjectionKernel injectionKernel = new InjectionKernel(manager,
                null,
                null,
                "RootScope",
                DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.ExportAssembly(GetType().Assembly));

            IAttributedActivationService activationService =
                injectionKernel.Locate<IAttributedActivationService>();

            Assert.NotNull(activationService);
            Assert.True(activationService.ContextActivationCalled);
            Assert.True(activationService.SimpleActivationCalled);
        }
示例#12
0
        public void ConstructorTargetInfoTest()
        {
            InjectionKernelManager manager = new InjectionKernelManager(null,
                DependencyInjectionContainer.CompareExportStrategies,
                new BlackList());
            InjectionKernel injectionKernel = new InjectionKernel(manager,
                null,
                null,
                null,
                DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(
                ioc =>
                {
                    ioc.ExportFunc((scope, context) =>
                                   {
                                       IInjectionTargetInfo targetInfo = context.TargetInfo;

                                       Assert.NotNull(targetInfo);

                                       Assert.NotNull(targetInfo.InjectionType);
                                       Assert.Equal(typeof(ImportConstructorService), targetInfo.InjectionType);

                                       Assert.NotNull(targetInfo.InjectionTypeAttributes);
                                       Assert.Equal(1, targetInfo.InjectionTypeAttributes.Count());

                                       Assert.NotNull(targetInfo.InjectionTarget);

                                       Assert.NotNull(targetInfo.InjectionTargetAttributes);
                                       Assert.Equal(1, targetInfo.InjectionTargetAttributes.Count());

                                       return new BasicService();
                                   }).As<IBasicService>();

                    ioc.Export<ImportConstructorService>().As<IImportConstructorService>();
                });

            IImportConstructorService importPropertyService = injectionKernel.Locate<IImportConstructorService>();

            Assert.NotNull(importPropertyService);
        }
        public void SingletonTest()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            Assembly assembly = GetType().Assembly;

            injectionKernel.Configure(c => c.ExportAssembly(assembly).ByInterface(typeof(ISimpleObject)).Lifestyle.Singleton());

            ISimpleObject simpleObject = injectionKernel.Locate<ISimpleObject>();

            Assert.NotNull(simpleObject);

            Assert.True(ReferenceEquals(simpleObject, injectionKernel.Locate<ISimpleObject>()));
        }
        public void ActivateMethods()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());

            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export<ActivateService>()
                .As<IActiveService>()
                .ActivationMethod(o => o.SimpleActivate())
                .ActivationMethod(o => o.InjectionContextActivate(null)));

            IActiveService activeService = injectionKernel.Locate<IActiveService>();

            Assert.NotNull(activeService);
            Assert.True(activeService.SimpleActivateCalled);
            Assert.True(activeService.InjectionContextActivateCalled);
        }
        public void RegisterAsTypeAndNameAndSingleton()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(
                c => c.Export<BasicService>().AsName("IBasicService").As<IBasicService>().Lifestyle.Singleton());

            IBasicService basicService = injectionKernel.Locate("IBasicService") as IBasicService;

            Assert.NotNull(basicService);

            IBasicService basicService2 = injectionKernel.Locate<IBasicService>();

            Assert.NotNull(basicService2);

            Assert.True(ReferenceEquals(basicService, basicService2));
        }
        public void WithCtorParamFiltered()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.ExportAssembly(GetType().Assembly).ByInterface(typeof(ISimpleObject));
                                          c.Export<ImportIEnumerableService>()
                                              .WithCtorParam<IEnumerable<ISimpleObject>>()
                                              .Consider((context, strategy) => strategy.ActivationName.EndsWith("C"));
                                      });

            ImportIEnumerableService import = injectionKernel.Locate<ImportIEnumerableService>();

            Assert.NotNull(import);
            Assert.Equal(1, import.Count);
        }
        public void WithCtorParamCollection()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export(Types.FromThisAssembly()).ByInterface(typeof(ISimpleObject)));
            injectionKernel.Configure(c =>
                c.Export<ImportListService>()
                    .WithCtorCollectionParam<List<ISimpleObject>, ISimpleObject>().
                    SortByProperty(p => p.TestString));

            ImportListService importListService = injectionKernel.Locate<ImportListService>();

            Assert.NotNull(importListService);
            Assert.Equal(5, importListService.SimpleObjects.Count);
            Assert.Equal("A", importListService.SimpleObjects[0].TestString);
            Assert.Equal("B", importListService.SimpleObjects[1].TestString);
            Assert.Equal("C", importListService.SimpleObjects[2].TestString);
            Assert.Equal("D", importListService.SimpleObjects[3].TestString);
            Assert.Equal("E", importListService.SimpleObjects[4].TestString);
        }
        public void RegisterImportMethod()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<BasicService>().As<IBasicService>();
                                          c.Export<ImportMethodService>()
                                              .As<IImportMethodService>()
                                              .ImportMethod(o => o.ImportMethod(null));
                                      });

            IImportMethodService importMethodService = injectionKernel.Locate<IImportMethodService>();

            Assert.NotNull(importMethodService);
            Assert.NotNull(importMethodService.BasicService);
        }
        public void UsingLifestyleContainerTest()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(
                c => c.Export<BasicService>().As<IBasicService>().UsingLifestyle(new SingletonLifestyle()));

            IBasicService basicService = injectionKernel.Locate<IBasicService>();

            Assert.NotNull(basicService);

            Assert.True(ReferenceEquals(basicService, injectionKernel.Locate<IBasicService>()));
        }
        public void RegisterWithoutAs()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export<BasicService>());

            BasicService basicService = injectionKernel.Locate<BasicService>();

            Assert.NotNull(basicService);
        }
        public void RegisterWeakSingleton()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export<BasicService>().As<IBasicService>().Lifestyle.WeakSingleton());

            IBasicService basicService = injectionKernel.Locate<IBasicService>();

            Assert.NotNull(basicService);

            Assert.True(ReferenceEquals(basicService, injectionKernel.Locate<IBasicService>()));

            IInjectionScope childScope = injectionKernel.CreateChildScope();

            IBasicService secondService = childScope.Locate<IBasicService>();

            Assert.NotNull(secondService);
            Assert.True(ReferenceEquals(basicService, secondService));
            Assert.True(ReferenceEquals(secondService, childScope.Locate<IBasicService>()));
        }
        public void RegisterImportPropertyWithFuncVale()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export<ImportPropertyService>()
                .As<IImportPropertyService>()
                .ImportProperty(o => o.BasicService).UsingValue(() => new BasicService()));

            IImportPropertyService importPropertyService = injectionKernel.Locate<IImportPropertyService>();

            Assert.NotNull(importPropertyService);
            Assert.NotNull(importPropertyService.BasicService);
        }
        public void RegisterImportPropertyWithFilter()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.ExportAssembly(GetType().Assembly).ByInterface(typeof(ISimpleObject));
                                          c.Export<ImportPropertySimpleObject>().
                                             ImportProperty(x => x.SimpleObject).Consider(ExportsThat.Activate(TypesThat.EndWith("C")));
                                      });

            ImportPropertySimpleObject import = injectionKernel.Locate<ImportPropertySimpleObject>();

            Assert.NotNull(import);
            Assert.NotNull(import.SimpleObject);
            Assert.IsType(typeof(SimpleObjectC), import.SimpleObject);
        }
        public void RegisterImportMethodWithDefaultsDictionary()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<BasicService>().As<IBasicService>();
                                          c.Export<ImportMethodWithArgs>()
                                              .ImportMethod(x => x.ImportMethod(null, null, 0))
                                              .WithMethodParam(() => "Hello").WithMethodParam(() => 7);
                                      });

            ImportMethodWithArgs import = injectionKernel.Locate<ImportMethodWithArgs>();

            Assert.NotNull(import);
            Assert.NotNull(import.BasicService);
            Assert.NotNull(import.StringParam);
            Assert.Equal("Hello", import.StringParam);
            Assert.Equal(7, import.IntParam);
        }
        public void RegisterArrayImport()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<SimpleObjectA>().As<ISimpleObject>();
                                          c.Export<SimpleObjectB>().As<ISimpleObject>();
                                          c.Export<SimpleObjectC>().As<ISimpleObject>();
                                          c.Export<SimpleObjectD>().As<ISimpleObject>();
                                          c.Export<SimpleObjectE>().As<ISimpleObject>();
                                          c.Export<ImportArrayService>().As<IImportArrayService>();
                                      });

            IImportArrayService arrayService = injectionKernel.Locate<IImportArrayService>();

            Assert.NotNull(arrayService);
        }
        public void AutoWireAllProperties()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<BasicService>().As<IBasicService>();
                                          c.Export<ImportConstructorService>().As<IImportConstructorService>();
                                          c.Export<ImportPropertyService>()
                                              .As<IImportPropertyService>()
                                              .ImportProperty(x => x.BasicService);
                                          c.Export<ImportMethodService>()
                                              .As<IImportMethodService>()
                                              .ImportMethod(o => o.ImportMethod(null));
                                          c.Export<MultiplePropertyImportService>()
                                              .As<IMultiplePropertyImportService>()
                                              .AutoWireProperties();
                                      });

            IMultiplePropertyImportService multiplePropertyImportService =
                injectionKernel.Locate<IMultiplePropertyImportService>();

            Assert.NotNull(multiplePropertyImportService);
            Assert.NotNull(multiplePropertyImportService.ConstructorService);
            Assert.NotNull(multiplePropertyImportService.MethodService);
            Assert.NotNull(multiplePropertyImportService.PropertyService);
        }
        public void PriorityTest()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<BasicService>().As<IBasicService>();
                                          c.Export<FauxBasicService>().As<IBasicService>().WithPriority(1);
                                      });

            IBasicService basicService = injectionKernel.Locate<IBasicService>();

            Assert.NotNull(basicService);
            Assert.IsType(typeof(FauxBasicService), basicService);
        }
        public void WhenMemberHas()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<SimpleObjectA>().As<ISimpleObject>();
                                          c.Export<SimpleObjectA>().As<ISimpleObject>();
                                          c.Export<SimpleObjectA>().As<ISimpleObject>();
                                          c.Export<SimpleObjectA>().As<ISimpleObject>().WhenMemberHas<SomeTestAttribute>();
                                          c.Export<SimpleObjectA>().As<ISimpleObject>().WhenMemberHas<SomeTestAttribute>();
                                          c.Export<AttributedMethodMultipleImport>().ImportMethod(x => x.ImportMethod(null));
                                          c.Export<AttributedPropertyMultipleImport>().ImportProperty(x => x.SimpleObjects);
                                          c.Export<ImportIEnumerableService>();
                                      });

            ImportIEnumerableService iEnumerableService = injectionKernel.Locate<ImportIEnumerableService>();

            Assert.NotNull(iEnumerableService);
            Assert.Equal(3, iEnumerableService.Count);

            AttributedMethodMultipleImport multipleImport = injectionKernel.Locate<AttributedMethodMultipleImport>();

            Assert.NotNull(multipleImport);
            Assert.Equal(5, multipleImport.Count);

            AttributedPropertyMultipleImport propertyMultipleImport = injectionKernel.Locate<AttributedPropertyMultipleImport>();

            Assert.NotNull(propertyMultipleImport);
            Assert.Equal(5, propertyMultipleImport.SimpleObjects.Length);
        }
        public void RegisterMultipleImportType()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c =>
                                      {
                                          c.Export<BasicService>().As<IBasicService>();
                                          c.Export<ImportConstructorService>().As<IImportConstructorService>();
                                          c.Export<ImportPropertyService>()
                                              .As<IImportPropertyService>()
                                              .ImportProperty(o => o.BasicService);
                                          c.Export<ImportAllTypes>()
                                              .ImportProperty(o => o.PropertyService)
                                              .ImportMethod(o => o.ImportMethod(null));
                                      });

            ImportAllTypes importAllTypes = injectionKernel.Locate<ImportAllTypes>();

            Assert.NotNull(importAllTypes);
            Assert.NotNull(importAllTypes.PropertyService);
            Assert.NotNull(importAllTypes.ImportConstructorService);
        }
        public void RegisterImportCollectionWithSort()
        {
            InjectionKernelManager injectionKernelManager =
                new InjectionKernelManager(null, DependencyInjectionContainer.CompareExportStrategies, new BlackList());
            InjectionKernel injectionKernel =
                new InjectionKernel(injectionKernelManager,
                    null,
                    null,
                    "RootScope",
                    DependencyInjectionContainer.CompareExportStrategies);

            injectionKernel.Configure(c => c.Export<ImportPropertyCollection>().ImportCollectionProperty(p => p.SimpleObjects));
        }