示例#1
0
        public IDependencyContainer BeginScope(Action <ContainerConfigurator> configuration = null)
        {
            var innerScope = new AutofacContainer();

            innerScope.AutofacScope = AutofacScope.BeginLifetimeScope(builder =>
            {
                new AutofacContainerBuilder(builder).Configure(configuration);
                innerScope.RegisterSelf(builder);
            });
            return(innerScope);
        }
示例#2
0
        public IDependencyContainerV2 BeginScope(LifetimeScope scope, Action <ContainerConfigurator> configuration = null)
        {
            var innerScope = new AutofacContainer();

            var autofacScope = scope.Equals(LifetimeScope.Local)
                ? new object()
                : scope;

            innerScope.AutofacScope = AutofacScope.BeginLifetimeScope(autofacScope, builder =>
            {
                new AutofacContainerBuilder(builder).Configure(configuration);
                innerScope.RegisterSelf(builder);
            });

            return(innerScope);
        }