我需要使用 spring.net 为接口的实现注入依赖项,使用属性注入。我不是很熟悉它,有人可以向我解释一下吗?
因此,在 config xml 文件中,对象是注入所需依赖项的类。所以 id 是该类的名称,但为什么不使用 name="PetStore" 代替呢?另外,类型是该类的完整路径,那么它后面的附加参数“PetStore”是什么?
关于属性, name 和 ref 指的是什么?名称是指在类“PetStore”中声明的属性,而 ref 是指接口的实现吗?
<object id="PetStore" type="PetStore.Services.PetStoreService, PetStore">
<property name="AccountDao" ref="AccountDao"/>
<property name="ItemDao" ref="ItemDao"/>
</object>
public class PetStore : IPetStore
{
public IAccountDao AccountDao { get; set; }
public IItemDao ItemDao{ get; set; }
}