我有一个few extensions methods我用我的asp.net web表单来管理网格视图行格式。有没有办法注入/交换扩展?
基本上,他们作为一种“服务”的,以我的代码隐藏类:
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
var row = e.Row;
if (row.RowType == DataControlRowType.DataRow)
{
decimal amount = Decimal.Parse(row.GetCellText("Spend"));
string currency = row.GetCellText("Currency");
row.SetCellText("Spend", amount.ToCurrency(currency));
row.SetCellText("Rate", amount.ToCurrency(currency));
row.ChangeCellText("Leads", c => c.ToNumber());
}
}
不像类的实例,他们没有与一个DI容器中使用的接口。
有什么方法可以获得可交换扩展的功能吗?
+1这小子让我想起了所谓的[提供商模式]的(http://msdn.microsoft.com/en -us /库/ ms972319.aspx) – 2012-03-18 00:38:27