所以,可以说,我有这个code
So lets say i have this code
var builder = new ContainerBuilder();
builder.RegisterInstance(new MyType());
var container = builder.Build();
然后一段时间后,我想改变的的MyType
的实例,未来所有可解析呼吁容器
Then some time later I want to change the instance of MyType
for all future resolves that are called on container
.
目前要变更登记,创建一次新 ContainerBuilder
,注册了新的实例,并调用更新
传递容器:
At the time you want to change the registration, create a new ContainerBuilder
, register the new instance, and call Update
passing in the container:
// at some later point...
builder = new ContainerBuilder();
builder.RegisterInstance(myType2);
builder.Update(container);