public virtual void Configure(IEngine engine, AutofacContainerManager containerManager) { //other dependencies containerManager.AddComponentInstance <IEngine>(engine, "Kore.Engine"); containerManager.AddComponentInstance <ContainerConfigurer>(this, "Kore.ContainerConfigurer"); //type finder containerManager.AddComponent <ITypeFinder, ConsoleAppTypeFinder>("Kore.TypeFinder"); //register dependencies provided by other assemblies var typeFinder = containerManager.Resolve <ITypeFinder>(); containerManager.UpdateContainer(x => { var drTypes = typeFinder.FindClassesOfType <IDependencyRegistrar <ContainerBuilder> >(); var drInstances = new List <IDependencyRegistrar <ContainerBuilder> >(); foreach (var drType in drTypes) { drInstances.Add((IDependencyRegistrar <ContainerBuilder>)Activator.CreateInstance(drType)); } //sort drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList(); foreach (var dependencyRegistrar in drInstances) { dependencyRegistrar.Register(x, typeFinder); } }); }
private void InitializeContainer(ContainerConfigurer configurer) { var builder = new ContainerBuilder(); var container = builder.Build(); _containerManager = new AutofacContainerManager(container); configurer.Configure(this, _containerManager); //_containerManager.NotifyCompleted(container); }