【发布时间】:2012-04-02 12:01:35
【问题描述】:
我有一个 few extensions methods 我用我的 asp.net 网络表单来管理网格视图行格式。
基本上,它们对我的类后面的代码充当一种“服务”:
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 容器一起使用的接口。
有没有办法获得可交换扩展的功能?
【问题讨论】:
标签: c# asp.net dependency-injection extension-methods mixins