public void RunOnceBeforeAny() { // Initialize configuration providers to use the actual web.config file, linked into this project from main web project var configSectionProvider = new ExternalConfigFileSectionProvider("web.config"); var configValueProvider = new ExternalConfigFileConfigValueProvider(configSectionProvider); var containerFactory = new InversionOfControlContainerFactory( configSectionProvider, configValueProvider); // Get the container Container = containerFactory.CreateContainer(c => { // Add the array resolver for resolving arrays of services automatically c.Kernel.Resolver.AddSubResolver(new ArrayResolver(c.Kernel)); // Make sure for this testing that we're using the config value provider initialized above c.Register(Component.For<IConfigSectionProvider>().Instance(configSectionProvider)); c.Register(Component.For<IConfigValueProvider>().Instance(configValueProvider)); // Initialize the service locator with the container // (enabling installers to access container through IoC during registration process) IoC.Initialize(c); }); // Register the wrapped service locator singleton instance Container = Container.Register( Component.For<IServiceLocator>() .Instance(IoC.WrappedServiceLocator)); }
/// <summary> /// Creates and initializes an instance of the <see cref="ExternalConfigFileConfigValueProvider"/> using /// the supplied <see cref="ExternalConfigFileSectionProvider"/> instance. /// </summary> /// <param name="configFileSectionProvider">The previously initialized config section provider that provides /// access to a specific external configuration file by path.</param> public ExternalConfigFileConfigValueProvider(ExternalConfigFileSectionProvider configFileSectionProvider) { this.configFileSectionProvider = configFileSectionProvider; }