0
有沒有辦法將當前作爲依賴項執行的IObjectFactory或ApplicationContext傳遞給對象?例如Spring.Net:注入ApplicationContext/ObjectFactory本身
<object id="SpringActionInvoker" type="xxx.SpringActionInvoker, xxx">
<constructor-arg ref="reference_to_the_ApplicationContext_or_ObjectFactor_that_is_executing" />
</object>
我想用我Spring.Net實施Asp.Net MVC ControllerActionInvoker的將被注入到控制器
public class SpringActionInvoker : ControllerActionInvoker
{
private IObjectFactory objectFactory;
public SpringActionInvoker(IObjectFactory objectFactory)
{
this.objectFactory = objectFactory;
}
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
//use objectFactory to inject dependencies into filters
}
}
我想將SpringActionInvoker放入實用工具類中,並且我並不總是使用app.config和ContextRegistry創建ObjectContext – Fabiano 2010-10-08 13:48:43