Exemple #1
0
 private AutofacObjectFactory(
     AutofacObjectFactory parentFactory,
     IAspectComposer aspects,
     Action cleanup)
     : this(parentFactory.CurrentScope, aspects)
 {
     this.ParentFactory = parentFactory;
     this.Cleanup       = cleanup;
 }
 private AutofacObjectFactory(
     AutofacObjectFactory parentFactory,
     IAspectComposer aspects,
     Action cleanup)
     : this(parentFactory.CurrentScope, 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;
 }
Exemple #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>().ExternallyOwned());
            factory.RegisterInterfaces(innerComposer);
            if (!string.IsNullOrEmpty(id))
            {
                TaggedScopes.TryAdd(id, factory);
            }
            return(factory);
        }