Example #1
0
        public IObjectFactory CreateScope(string id)
        {
            BuildScopeIfRequired();
            var innerComposer = Aspects.CreateInnerComposer();
            DryIocObjectFactory tv;
            Action cleanup = string.IsNullOrEmpty(id) ? (Action)null : () => TaggedScopes.TryRemove(id, out tv);
            var    factory = new DryIocObjectFactory(this, innerComposer, cleanup);

            factory.RegisterInstance <IObjectFactory>(factory);
            factory.RegisterInterfaces(innerComposer);
            if (!string.IsNullOrEmpty(id))
            {
                TaggedScopes.TryAdd(id, factory);
            }
            return(factory);
        }
Example #2
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);
        }