Resolving IEnumerable with Unity

前端 未结 8 1083
梦如初夏
梦如初夏 2020-12-04 22:05

Can Unity automatically resolve IEnumerable?

Let\'s say I have a class with this constructor:

public CoalescingParserSelector(I         


        
8条回答
  •  萌比男神i
    2020-12-04 22:27

    It turns out that this is actually awfully simple to do:

    container.RegisterType, IParserBuilder[]>();
    

    Unity natively understands arrays, so we just need to map the enumerable to an array of the same type.

提交回复
热议问题