我开始使用Simple Injector作为我的DI容器(主要是出于性能原因,如果有建议,请告诉我),但我编写的一些类使用HttpContextBase作为构造函数参数。 目前我已解决该问题,将其从构造函数中移除并创建一个属性,类似于以下内容:
public HttpContextBase HttpContext
{
get
{
if (null == _httpContext)
_httpContext = new HttpContextWrapper(System.Web.HttpContext.Current);
return _httpContext;
}
set
{
_httpContext = value;
}
}
但我不喜欢这个解决方案... 有什么建议吗?