1
我試圖使用Autofac OnActivated創建一個類Autofac OnActivated不工作/調用
除了
builder.Register(c => new MyThing(c.Resolve<MyOtherThingDependancy>()))
.As<IMyThing>()
.SingleInstance()
.OnActivated(c=> new MyOtherThing(c.Instance)); // i only need this to be instantiated once
MyOtherThing的線條具有類似構造函數:
public MyOtherThing(IMyThing myThing)
然而,它不是射擊
MyOtherThing
永遠不會被實例化
我在做什麼錯?
我不知道AutoActivate的....我沒有看到它的文檔,但已經我同意,更加清晰的意圖! – Alex