What is the AutoFac equivalent of the Unity liftetime HierarchicalLifetimeManager?

68 Views Asked by At

I am attempting to convert the below unity container registration into an AutoFac container

container.RegisterType<C1Context>(new HierarchicalLifetimeManager());
container.RegisterFactory<I1CallContext>(c => c.Resolve<C1Context>());
container.RegisterFactory<I2CallContext>(c => c.Resolve<C1Context>());

I got as close as the below in autofac:

container.RegisterType<C1Context>()
    .As<I1CallContext, I2CallContext>()
    .InstancePerLifetimeScope();

The components are registered as expected, however the lifetime does not seem to match up with Unity - have I configured this incorrectly? I have tried many different implementations with no luck.

0

There are 0 best solutions below