Skip to content

Commit

Permalink
#1935 Fixed Autofac warnings. 'ContainerBuilder.Update(IContainer)' m…
Browse files Browse the repository at this point in the history
…ethod is obsolete
  • Loading branch information
AndreiMaz committed Dec 12, 2016
1 parent fa4edf6 commit 9367ae4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Libraries/Nop.Core/Infrastructure/NopEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<NopConfig>().SingleInstance();
builder.RegisterInstance(this).As<IEngine>().SingleInstance();
builder.RegisterInstance(typeFinder).As<ITypeFinder>().SingleInstance();
builder.Update(container);

//register dependencies provided by other assemblies
builder = new ContainerBuilder();
var drTypes = typeFinder.FindClassesOfType<IDependencyRegistrar>();
var drInstances = new List<IDependencyRegistrar>();
foreach (var drType in drTypes)
Expand All @@ -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));
Expand Down

0 comments on commit 9367ae4

Please sign in to comment.