StructureMap Beginner | Property Injection

后端 未结 2 1661
我在风中等你
我在风中等你 2020-12-03 09:19

Part of this question was already asked here : structuremap Property Injection but the answer was never given.

With StructureMap, is it possible to do Property Injec

2条回答
  •  生来不讨喜
    2020-12-03 09:23

    To inject dependencies for all properties of a certain type, use the SetAllProperties method as part of the initialization of your ObjectFactory:

    ObjectFactory.Initialize(x =>
    {
       x.SetAllProperties(x => x.OfType());
    });
    

    It is also possible to define policies for setter injection, see this post.

提交回复
热议问题