/// <summary> /// Builds this instance. /// </summary> /// <returns>IContainer.</returns> public IContainer Build() { Composer.Register( Scanner, this, typeof(IServiceConvention), typeof(IAutofacConvention), typeof(ServiceConventionDelegate), typeof(AutofacConventionDelegate) ); _collection.Apply(_containerBuilder); _containerBuilder.Populate(Services); var result = _containerBuilder.Build(); #pragma warning disable CA2000 // Dispose objects before losing scope var sp = new AutofacServiceProvider(result); #pragma warning restore CA2000 // Dispose objects before losing scope _serviceProviderOnBuild.Send(sp); _containerObservable.Send(result); return(result); }
/// <summary> /// Builds this instance. /// </summary> /// <returns>IContainer.</returns> public IContainer Build() { var options = this.GetOrAdd(() => new DryIocOptions()); Composer.Register( Scanner, this, typeof(IServiceConvention), typeof(IDryIocConvention), typeof(ServiceConventionDelegate), typeof(DryIocConventionDelegate) ); _container.Populate(Services); _serviceProviderOnBuild.Send(_container); _containerObservable.Send(_container); _container = options.NoMoreRegistrationAllowed ? _container.WithNoMoreRegistrationAllowed() : _container; return(_container); }