2009-01-19 137 views

回答

31

基本上,这告诉Unity使用该属性指定的构造函数。请致电read this post了解更多信息。

0

此属性用于指示在容器尝试构建类型时要选择哪个构造函数。

myclass { 

[InjectionConstructor] 
public myclass(interface1:XYZ, .....){} 
} 

它以更具说明性的方式做类似于InjectionConstructor(不属性)的东西。但它缺少一些功能,如使用命名界面ex:

new InjectionConstructor(new ResolvedParameter<IMyInterface>("implementation # 1"));