private static void ConfigureModule(IContainerConfigurator configurator, IUnityContainer container) { if (configurator != null) { configurator.Configure(container); } }
public CQRSBuilder(IContainerConfigurator container) { Container = container ?? throw new ArgumentNullException(nameof(container)); CommandExecutionPipelineBuilder = new CommandExecutionPipelineBuilder(container); QueryExecutionPipelineBuilder = new QueryExecutionPipelineBuilder(container); NotificationExecutionPipelineBuilder = new NotificationExecutionPipelineBuilder(container); }
internal StashboxContainer(IStashboxContainer parentContainer, IContainerExtensionManager containerExtensionManager, IResolverSelector resolverSelector, IContainerConfigurator containerConfigurator, IDecoratorRepository decoratorRepository) : this(containerExtensionManager, resolverSelector, containerConfigurator, decoratorRepository) { this.ParentContainer = parentContainer; this.containerExtensionManager.ReinitalizeExtensions(this.ContainerContext); }
internal ServiceRegistration(Type implementationType, IContainerConfigurator containerConfigurator, IObjectBuilderSelector objectBuilderSelector, RegistrationContextData registrationContextData, bool isDecorator, bool shouldHandleDisposal) { this.containerConfigurator = containerConfigurator; this.objectBuilderSelector = objectBuilderSelector; this.ImplementationType = implementationType; this.metaInformation = MetaInformation.GetOrCreateMetaInfo(implementationType); this.Constructors = this.metaInformation.GetConstructors(); this.InjectionMethods = this.metaInformation.GetInjectionMethods(); this.InjectionMembers = this.metaInformation.SelectInjectionMembers(registrationContextData, containerConfigurator.ContainerConfiguration); this.SelectedConstructor = this.metaInformation.FindSelectedConstructor(registrationContextData); this.RegistrationNumber = ReserveRegistrationNumber(); this.RegistrationContext = registrationContextData; this.IsDecorator = isDecorator; this.ShouldHandleDisposal = shouldHandleDisposal; this.HasName = this.RegistrationContext.Name != null; this.HasScopeName = this.RegistrationContext.Lifetime is NamedScopeLifetime; this.HasCondition = this.RegistrationContext.TargetTypeCondition != null || this.RegistrationContext.ResolutionCondition != null || this.RegistrationContext.AttributeConditions != null && this.RegistrationContext.AttributeConditions.Any(); this.RegistrationId = this.RegistrationContext.Name ?? (containerConfigurator.ContainerConfiguration.SetUniqueRegistrationNames ? (object)this.RegistrationNumber : implementationType); this.objectBuilder = this.SelectObjectBuilder(); }
static void ConfigureContainer() { if (!IsInitialized) { var configTypes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(asm => asm.GetTypes().Where(type => type.GetInterface("IContainerConfigurator") == typeof(IContainerConfigurator))) .ToList(); if (configTypes.Count() == 0) { throw new InvalidOperationException($"{nameof(DependencyInjection)} could not locate {nameof(IContainerConfigurator)}"); } else if (configTypes.Count > 1) { throw new InvalidOperationException($"{nameof(DependencyInjection)} found multiple {nameof(IContainerConfigurator)}"); } IContainerConfigurator configurator = null; try { configurator = (IContainerConfigurator)Activator.CreateInstance(configTypes.Single()); } catch (Exception exn) { throw new InvalidOperationException($"{nameof(DependencyInjection)} could not create instance of {nameof(IContainerConfigurator)}", exn); } var services = new ServiceCollection(); configurator.Configure(services); serviceProvider = services.BuildServiceProvider(); IsInitialized = true; } }
public BootstrapFeature( IFileSystem fileSystem, ICakeEnvironment environment, IContainerConfigurator configurator) : base(fileSystem, environment, configurator) { _environment = environment; }
internal ServiceRegistration(Type serviceType, Type implementationType, IContainerConfigurator containerConfigurator, IObjectBuilder objectBuilder, RegistrationContextData registrationContextData, bool isDecorator, bool shouldHandleDisposal) { this.objectBuilder = objectBuilder; this.containerConfigurator = containerConfigurator; this.ImplementationType = implementationType; this.ServiceType = serviceType; this.MetaInformation = GetOrCreateMetaInfo(implementationType, registrationContextData); this.RegistrationNumber = ReserveRegistrationNumber(); this.RegistrationContext = registrationContextData; this.IsDecorator = isDecorator; this.ShouldHandleDisposal = shouldHandleDisposal; this.HasName = this.RegistrationContext.Name != null; this.HasScopeName = this.RegistrationContext.Lifetime is NamedScopeLifetime; this.HasCondition = this.RegistrationContext.TargetTypeCondition != null || this.RegistrationContext.ResolutionCondition != null || this.RegistrationContext.AttributeConditions != null && this.RegistrationContext.AttributeConditions.Count > 0; this.RegistrationId = this.RegistrationContext.Name ?? (containerConfigurator.ContainerConfiguration.SetUniqueRegistrationNames ? (object)this.RegistrationNumber : implementationType); }
public Feature( IFileSystem fileSystem, ICakeEnvironment environment, IContainerConfigurator configurator) { _fileSystem = fileSystem; _environment = environment; _configurator = configurator; }
internal ContainerContext(IRegistrationRepository registrationRepository, IStashboxContainer container, IResolutionStrategy resolutionStrategy, IContainerConfigurator containerConfigurator, IDecoratorRepository decoratorRepository) { this.ResolutionStrategy = resolutionStrategy; this.RegistrationRepository = registrationRepository; this.Container = container; this.ContainerConfigurator = containerConfigurator; this.DecoratorRepository = decoratorRepository; }
/// <summary> /// Read the current Enterprise Library configuration in the given <paramref name="configSource"/> /// and supply the corresponding type information to the <paramref name="configurator"/>. /// </summary> /// <param name="locator"><see cref="TypeRegistrationsProvider"/> used to identify what information /// to pull from the configuration file.</param> /// <param name="configurator"><see cref="IContainerConfigurator"/> object used to consume the configuration /// information.</param> /// <param name="configSource">Configuration information.</param> public static void ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource) { if (configurator == null) throw new ArgumentNullException("configurator"); configurator.RegisterAll(configSource, locator); }
/// <summary> /// Read the current Enterprise Library configuration in the given <paramref name="configSource"/> /// and supply the corresponding type information to the <paramref name="configurator"/>. /// </summary> /// <param name="locator"><see cref="TypeRegistrationsProvider"/> used to identify what information /// to pull from the configuration file.</param> /// <param name="configurator"><see cref="IContainerConfigurator"/> object used to consume the configuration /// information.</param> /// <param name="configSource">Configuration information.</param> public static void ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource) { if (configurator == null) { throw new ArgumentNullException("configurator"); } configurator.RegisterAll(configSource, locator); }
/// <summary> /// Read the current Enterprise Library configuration in the given <paramref name="configSource"/> /// and supply the corresponding type information to the <paramref name="configurator"/>. /// </summary> /// <param name="configurator"><see cref="IContainerConfigurator"/> object used to consume the configuration /// information.</param> /// <param name="configSource">Configuration information.</param> public static void ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource) { var reconfiguringEventSource = configurator as IContainerReconfiguringEventSource ?? new NullContainerReconfiguringEventSource(); ConfigureContainer( TypeRegistrationsProvider.CreateDefaultProvider(configSource, reconfiguringEventSource), configurator, configSource); }
public BuildFeature( IFileSystem fileSystem, ICakeEnvironment environment, IContainerConfigurator configurator, IModuleSearcher searcher, ICakeLog log) : base(fileSystem, environment, configurator) { _environment = environment; _searcher = searcher; _log = log; }
// C'tor public TestWebServer(IContainerConfigurator containerConfigurator = null) { var builder = new WebHostBuilder() .ConfigureServices(services => { services.AddSingleton(containerConfigurator ?? new ContainerConfigurator(null)); }) .UseStartup <TestStartup>(); _server = new TestServer(builder); }
/// <summary> /// Read the current Enterprise Library configuration in the given <paramref name="configSource"/> /// and supply the corresponding type information to the <paramref name="configurator"/>. /// </summary> /// <param name="configurator"><see cref="IContainerConfigurator"/> object used to consume the configuration /// information.</param> /// <param name="configSource">Configuration information.</param> public static void ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource) { var reconfiguringEventSource = configurator as IContainerReconfiguringEventSource ?? new NullContainerReconfiguringEventSource(); ConfigureContainer( TypeRegistrationsProvider.CreateDefaultProvider(configSource, reconfiguringEventSource), configurator, configSource); }
internal StashboxContainer(IContainerExtensionManager containerExtensionManager, IResolverSelector resolverSelector, IContainerConfigurator containerConfigurator, IDecoratorRepository decoratorRepository, Action <IContainerConfigurator> config = null) { this.containerExtensionManager = containerExtensionManager; this.resolverSelector = resolverSelector; config?.Invoke(containerConfigurator); this.ContainerContext = new ContainerContext(this.registrationRepository, this, new ResolutionStrategy(this.resolverSelector), containerConfigurator, decoratorRepository); var expressionBuilder = new ExpressionBuilder(this.containerExtensionManager, new ConstructorSelector()); this.serviceRegistrator = new ServiceRegistrator(this.ContainerContext, this.containerExtensionManager); this.objectBuilderSelector = new ObjectBuilderSelector(expressionBuilder, this.serviceRegistrator); this.registrationBuilder = new RegistrationBuilder(this.ContainerContext, this.objectBuilderSelector); this.RootScope = new ResolutionScope(this.resolverSelector, expressionBuilder, this.ContainerContext); this.rootResolver = (IDependencyResolver)this.RootScope; }
public CommandExecutionPipelineBuilder(IContainerConfigurator container) { _container = container ?? throw new ArgumentNullException(nameof(container)); _stepCoordinator = new PipelineStepCoordinator <ICommandPipelineStep>(); }
public static void AddScope <TInterface, TImplementation>(this IContainerConfigurator container) where TImplementation : class, TInterface { container.AddScope(typeof(TInterface), typeof(TImplementation)); }
public static bool HasComponent <TServiceType>(this IContainerConfigurator container) { return(container.HasComponent(typeof(TServiceType))); }
public static void AddSingleton <TInterface, TImplementation>(this IContainerConfigurator container) where TImplementation : class, TInterface { container.Add(DependencyLifetime.Singleton, typeof(TInterface), typeof(TImplementation)); }
public static void AddScope(this IContainerConfigurator container, Type interfaceDefinition, Type implementation) { container.Add(DependencyLifetime.Scoped, interfaceDefinition, implementation); }
// C'tor public TestStartup(IHostingEnvironment env, IContainerConfigurator containerConfigurator) : base(env) { _containerConfigurator = containerConfigurator; _uniqueDbName = Guid.NewGuid().ToString(); }
public void TestConfigurator() { IContainerConfigurator containerConfigurator = internalContainer.Configurator; Assert.That(containerConfigurator, Is.InstanceOf <ContainerConfigurator>()); }
internal ContainerContext(IRegistrationRepository registrationRepository, IDelegateRepository delegateRepository, IStashboxContainer container, IResolutionStrategy resolutionStrategy, IContainerConfigurator containerConfigurator, IDecoratorRepository decoratorRepository) { this.ResolutionStrategy = resolutionStrategy; this.RegistrationRepository = registrationRepository; this.DelegateRepository = delegateRepository; this.Container = container; this.Bag = new ConcurrentKeyValueStore <object, object>(); this.ContainerConfigurator = containerConfigurator; this.DecoratorRepository = decoratorRepository; }
public ContainerWrapper(IContainerConfigurator <TContainer> context) { _context = context; }
public static void MakeCloud(IContainerConfigurator configurator) => Of(configurator.Configure) .Then(MakeCloud) .OnFail(Console.WriteLine);