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())); }
public AbstractionConfigurator(IAbstractionConfigurationCollection abstractionConfigurationCollection, IClassWrapperCreator classWrapperCreator, IImplementationConfigurationCache implementationConfigurationCache, IImplementationCache implementationCache) { worker = new AbstractionConfigurator(typeof(T), abstractionConfigurationCollection, classWrapperCreator, implementationConfigurationCache, implementationCache); }
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())); }
public static IContainer CreateWithChilds(IContainerConfiguration configuration, IClassWrapperCreator classWrapperCreator, IContainerSelector selector) { return (new Container( new InternalContainer(new CompositeContainerContext(configuration, classWrapperCreator, selector)), new NoContextHolder(), null)); }
public ContainerConfigurator(IAbstractionConfigurationCollection abstractionConfigurationCollection, IClassWrapperCreator classWrapperCreator, IImplementationConfigurationCache implementationConfigurationCache, IImplementationCache implementationCache) { this.abstractionConfigurationCollection = abstractionConfigurationCollection; this.classWrapperCreator = classWrapperCreator; this.implementationConfigurationCache = implementationConfigurationCache; this.implementationCache = implementationCache; }
public InstanceImplementationConfiguration(IClassWrapperCreator classWrapperCreator, object instance) { if (classWrapperCreator != null && ReferenceEquals(instance, classWrapperCreator.UnWrap(instance))) { this.instance = classWrapperCreator.WrapAndCreate(instance); } else { this.instance = instance; } ObjectType = instance.GetType(); }
public InstanceAbstractionConfiguration(IClassWrapperCreator classWrapperCreator, Type abstractionType, object[] instances) { if (instances == null || instances.Length == 0) { throw new ArgumentException("instances"); } implementationConfigurations = new IImplementationConfiguration[instances.Length]; for (var i = 0; i < implementationConfigurations.Length; i++) { var type = instances[i].GetType(); if (!abstractionType.IsAssignableFrom(type)) { throw new ArgumentException($"Instances of type {type} cannot be used as abstraction of type {abstractionType}"); } implementationConfigurations[i] = new InstanceImplementationConfiguration(classWrapperCreator, instances[i]); } }
public InstanceAbstractionConfiguration(IClassWrapperCreator classWrapperCreator, Type abstractionType, object[] instances) { if (instances == null || instances.Length == 0) { throw new ArgumentException("instances"); } implementationConfigurations = new IImplementationConfiguration[instances.Length]; for (int i = 0; i < implementationConfigurations.Length; i++) { Type type = instances[i].GetType(); if (!abstractionType.IsAssignableFrom(type)) { throw new ArgumentException("Заданная реализация на являются объектами типа " + abstractionType + " (реальный тип " + type + ")"); } implementationConfigurations[i] = new InstanceImplementationConfiguration(classWrapperCreator, instances[i]); } }
public Container(IContainerConfiguration configuration, IClassWrapperCreator classWrapperCreator) : this(new InternalContainer(configuration, classWrapperCreator), NoContextHolder.Instance, null) { }
public InternalContainer(IContainerConfiguration configuration, IClassWrapperCreator classWrapperCreator) : this(new ContainerContext(configuration, classWrapperCreator)) { }
public CreationContext(IClassCreator classCreator, IConstructorSelector constructorSelector, IClassWrapperCreator classWrapperCreator) { this.classCreator = classCreator; this.constructorSelector = constructorSelector; this.classWrapperCreator = classWrapperCreator; }