Beispiel #1
0
		private AutofacObjectFactory(
			AutofacObjectFactory parentFactory,
			IAspectComposer aspects,
			Action cleanup)
			: this(parentFactory.CurrentScope.BeginLifetimeScope(), aspects)
		{
			this.ParentFactory = parentFactory;
			this.Cleanup = cleanup;
		}
Beispiel #2
0
 private AutofacObjectFactory(
     AutofacObjectFactory parentFactory,
     IAspectComposer aspects,
     Action cleanup)
     : this(parentFactory.CurrentScope.BeginLifetimeScope(), aspects)
 {
     this.ParentFactory = parentFactory;
     this.Cleanup       = cleanup;
 }
 public IObjectFactory CreateScope(string id)
 {
     BuildScopeIfRequired();
     var innerComposer = Aspects.CreateInnerComposer();
     AutofacObjectFactory tv;
     Action cleanup = string.IsNullOrEmpty(id) ? (Action)null : () => TaggedScopes.TryRemove(id, out tv);
     var factory = new AutofacObjectFactory(this, innerComposer, cleanup);
     factory.AutofacBuilders.Add(cb => cb.RegisterInstance(factory).As<IObjectFactory>().ExternallyOwned());
     factory.RegisterInterfaces(innerComposer);
     if (!string.IsNullOrEmpty(id))
         TaggedScopes.TryAdd(id, factory);
     return factory;
 }
Beispiel #4
0
        public IObjectFactory CreateScope(string id)
        {
            BuildScopeIfRequired();
            var innerComposer = Aspects.CreateInnerComposer();
            AutofacObjectFactory tv;
            Action cleanup = string.IsNullOrEmpty(id) ? (Action)null : () => TaggedScopes.TryRemove(id, out tv);
            var    factory = new AutofacObjectFactory(this, innerComposer, cleanup);

            factory.AutofacBuilders.Add(cb => cb.RegisterInstance(factory).As <IObjectFactory>().As <IServiceProvider>().ExternallyOwned());
            factory.RegisterInterfaces(innerComposer);
            if (!string.IsNullOrEmpty(id))
            {
                TaggedScopes.TryAdd(id, factory);
            }
            return(factory);
        }