UserControl
UserControl

Reputation: 15179

Autofac equivalent of Unity's InjectionFactory

I need to translate the following Unity snippet to Autofac implementation:

        container.RegisterType<IMyThing>(
            new TransientLifetimeManager(),
            new InjectionFactory(c => c.Resolve<IMyThingProvider>().GetTheThing()));

What's the equivalent of InjectionFactory?

Upvotes: 0

Views: 357

Answers (1)

Alistair Evans
Alistair Evans

Reputation: 36513

I believe you want to use a lambda registration:

container.Register(ctxt => ctxt.Resolve<IMyThingProvider>().GetTheThing())
         .As<IMyThing>();

Upvotes: 4

Related Questions