public CompositeContainerContext(IContainerConfiguration configuration, IClassWrapperCreator classWrapperCreator,
                                         IContainerSelector containerSelector)
        {
            this.Configuration  = configuration;
            ClassWrapperCreator = classWrapperCreator;
            typesHelper         = new TypesHelper();

            var funcHelper = new FuncHelper();

            FuncBuilder = new FuncBuilder();
            var classCreator        = new ClassCreator(funcHelper);
            var constructorSelector = new ConstructorSelector();

            CreationContext = new CreationContext(classCreator, constructorSelector, classWrapperCreator);

            var implementationTypesCollection = new ImplementationTypesCollection(configuration, typesHelper);

            ImplementationCache              = new ImplementationCache();
            abstractionsCollection           = new AbstractionsCollection(implementationTypesCollection, ImplementationCache);
            ImplementationConfigurationCache = new ImplementationConfigurationCache();
            var factory = new AutoAbstractionConfigurationFactory(typesHelper, abstractionsCollection,
                                                                  ImplementationConfigurationCache);

            compositeCollection = new CompositeCollection(new[] { new AbstractionConfigurationCollection(factory) },
                                                          containerSelector);
            compositeCollection.Add(typeof(IContainer),
                                    new StupidAbstractionConfiguration(
                                        new ContainerImplementationConfiguration()));
        }
예제 #2
0
        public override void SetUp()
        {
            base.SetUp();
            var configuration = new ContainerConfiguration(new[] { GetType().Assembly });

            selector  = new RootAndChildSelector();
            container = Container.CreateWithChilds(configuration, null, selector);
        }
예제 #3
0
 public CompositeCollection(IAbstractionConfigurationCollection[] rootToChildCollections,
                            IContainerSelector selector)
 {
     if (rootToChildCollections == null || rootToChildCollections.Length == 0)
     {
         throw new ArgumentException("rootToChildCollections");
     }
     containerTreeDepth          = rootToChildCollections.Length - 1;
     this.rootToChildCollections = rootToChildCollections;
     leafCollection = rootToChildCollections[containerTreeDepth];
     this.selector  = selector;
 }
예제 #4
0
 public static void Scan(this IContainerSelector container, IEnumerable <Assembly> assemlies)
 {
     foreach (var type in assemlies.SelectMany(assembly => assembly.GetTypes().Where(x =>
                                                                                     typeof(WiringContainer).IsAssignableFrom(x) && x != typeof(WiringContainer))))
     {
         try
         {
             container.With(type);
         }
         catch (Exception e)
         {
             throw new Exception("AssemblyScanner failed.", e);
         }
     }
 }
예제 #5
0
 public static IContainer CreateWithChilds(IContainerConfiguration configuration, IClassWrapperCreator classWrapperCreator, IContainerSelector selector)
 {
     return(new Container(new InternalContainer(new CompositeContainerContext(configuration, classWrapperCreator, selector)), NoContextHolder.Instance, null));
 }