开发者

Unity Application Block - Constructor injection in configuration file

开发者 https://www.devze.com 2023-01-14 09:06 出处:网络
How can I specify that constructor with no parameter should be used while creating the object? I know how to do it for the parameterized one but cannot find any help for the parameter less constructor

How can I specify that constructor with no parameter should be used while creating the object? I know how to do it for the parameterized one but cannot find any help for the parameter less constructor.

I know how开发者_开发知识库 to do this through code but need solution for doing it through configuration.


Could you just specify an empty constructor node in the config?

<types>
    <type type="MyProject.IRepository, MyProject, Version=1.0.0.0, Culture=neutral"
          mapTo="MyProject.DefaultRepository, MyProject, Version=1.0.0.0, Culture=neutral">
        <lifetime type="transient" />
        <typeConfig>
            <constructor>
            </constructor>
        </typeConfig>
    </type>
</types>
0

精彩评论

暂无评论...
验证码 换一张
取 消