/// <summary> ///Register Dependencies/// </summary> /// <param name= "config" >Config</param> protected Virtual voidregisterdependencies (nopconfig config) {varBuilder =NewContainerbuilder (); varcontainer =Builder. Build (); This. _containermanager =NewContainermanager (container); //We create new instance of Containerbuilder//because Build () or Update () method can is called once on a containerbuilder. //Dependencies varTypeFinder =NewWebapptypefinder (); Builder=NewContainerbuilder (); 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 assembliesBuilder =NewContainerbuilder (); varDrtypes = typefinder.findclassesoftype<idependencyregistrar>(); varDrinstances =NewList<idependencyregistrar>(); foreach(varDrtypeinchdrtypes) Drinstances.add ((Idependencyregistrar) activator.createinstance (Drtype)); //SortDrinstances = Drinstances.asqueryable (). (t =t.order). ToList (); foreach(varDependencyregistrarinchdrinstances) Dependencyregistrar.register (builder, TypeFinder, config); Builder. Update (container); //Set Dependency resolverDependencyresolver.setresolver (NewAutofacdependencyresolver (container)); } #endregion
Nopcommerce Source Analysis Containerbuilder Builder. Update (Container)