From 9367ae4a4f800f57db4afa9f2c3954d08b20d02a Mon Sep 17 00:00:00 2001 From: AndreiMaz Date: Mon, 12 Dec 2016 18:22:03 +0300 Subject: [PATCH] #1935 Fixed Autofac warnings. 'ContainerBuilder.Update(IContainer)' method is obsolete --- src/Libraries/Nop.Core/Infrastructure/NopEngine.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Libraries/Nop.Core/Infrastructure/NopEngine.cs b/src/Libraries/Nop.Core/Infrastructure/NopEngine.cs index 9589ef6b200..0dd9cd58540 100644 --- a/src/Libraries/Nop.Core/Infrastructure/NopEngine.cs +++ b/src/Libraries/Nop.Core/Infrastructure/NopEngine.cs @@ -47,22 +47,14 @@ protected virtual void RunStartupTasks() protected virtual void RegisterDependencies(NopConfig config) { var builder = new ContainerBuilder(); - var container = builder.Build(); - this._containerManager = new ContainerManager(container); - - //we create new instance of ContainerBuilder - //because Build() or Update() method can only be called once on a ContainerBuilder. - + //dependencies var typeFinder = new WebAppTypeFinder(); - builder = new ContainerBuilder(); builder.RegisterInstance(config).As().SingleInstance(); builder.RegisterInstance(this).As().SingleInstance(); builder.RegisterInstance(typeFinder).As().SingleInstance(); - builder.Update(container); //register dependencies provided by other assemblies - builder = new ContainerBuilder(); var drTypes = typeFinder.FindClassesOfType(); var drInstances = new List(); foreach (var drType in drTypes) @@ -71,7 +63,9 @@ protected virtual void RegisterDependencies(NopConfig config) drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList(); foreach (var dependencyRegistrar in drInstances) dependencyRegistrar.Register(builder, typeFinder, config); - builder.Update(container); + + var container = builder.Build(); + this._containerManager = new ContainerManager(container); //set dependency resolver DependencyResolver.SetResolver(new AutofacDependencyResolver(container));