I have the following setup
public class CommonClass : ICommonClass
{
}
public class SomeClass : ISomeClass
{
public SomeClass(ICommonClass common, IOtherClass otherClass) {}
}
public class OtherClass : IOtherClass
{
public OtherClass(ICommonClass common) {}
}
//Registration
builder.RegisterType<CommonClass>().As<ICommonClass>().InstancePerDependency();
builder.RegisterType<SomeClass>().As<ISomeClass>().InstancePerDependency();
builder.RegisterType<OtherClass>().As<IOtherClass>().InstancePerDependency();
I would like the common argument in each constructor to be the same instance, but for it to create new instance of ICommon when SomeClass is resolved. How can I get this time happen. I attempted to register them as InstancePerLifetimeScope but it acted the same as SingleInstance.