Ejemplo n.º 1
0
        public ContainerContext(IContainerConfiguration configuration, IClassWrapperCreator classWrapperCreator)
        {
            Configuration       = configuration;
            ClassWrapperCreator = classWrapperCreator;
            ITypesHelper 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.GetTypesToScan(), typesHelper);

            ImplementationCache = new ImplementationCache();
            IAbstractionsCollection abstractionsCollection = new AbstractionsCollection(implementationTypesCollection, ImplementationCache);

            ImplementationConfigurationCache = new ImplementationConfigurationCache(); //l
            var factory = new AutoAbstractionConfigurationFactory(typesHelper, abstractionsCollection, ImplementationConfigurationCache);

            AbstractionConfigurationCollection = new AbstractionConfigurationCollection(factory);
            AbstractionConfigurationCollection.Add(typeof(IContainer), new StupidAbstractionConfiguration(new ContainerImplementationConfiguration()));
        }
Ejemplo n.º 2
0
        private CompositeContainerContext(CompositeContainerContext source)
        {
            Configuration   = source.Configuration;
            typesHelper     = source.typesHelper;
            FuncBuilder     = source.FuncBuilder;
            CreationContext = source.CreationContext;

            //NOTE чтобы дочерние контейнеры не тормозили, используем ту же AbstractionsCollection
            abstractionsCollection = source.abstractionsCollection;
            ImplementationCache    = source.ImplementationCache;

            ImplementationConfigurationCache = new ImplementationConfigurationCache();
            var factory = new AutoAbstractionConfigurationFactory(typesHelper, abstractionsCollection, ImplementationConfigurationCache);
            //NOTE для каждого экземпляра контейнера должна быть своя AbstractionConfigurationCollection
            var abstractionConfigurationCollection = new AbstractionConfigurationCollection(factory);

            compositeCollection = source.compositeCollection.MakeChildCollection(abstractionConfigurationCollection);
            compositeCollection.Add(typeof(IContainer), new StupidAbstractionConfiguration(new ContainerImplementationConfiguration()));
        }
 public override void SetUp()
 {
     base.SetUp();
     factory = GetMock <IAutoAbstractionConfigurationFactory>();
     configurationCollection = new AbstractionConfigurationCollection(factory);
 }