【发布时间】:2011-09-09 17:38:43
【问题描述】:
我有接受不同输入的方法调用,即:
public Authors GetAuthors(string name, string sortBy, string sortDir, int startRow, int numRow)
{
// Get authors based on filters
}
public Books GetBooks(string id, string year, string sortBy, string sorDir, int startRow, int numRow)
{
// Get books based on filters
}
我打算将其更改为过滤器是对象,即:
public Authors GetAuthors(GetAuthorsFilters filters)
{
// Get authors based on filters
}
public Books GetBooks(GetBooksFilters filters)
{
// Get books based on filters
}
但是许多过滤器在这些方法中是通用的,我想为此构建一个通用接口(即IFilter),它可以采用不同的过滤器对象,但不确定从哪里开始。有什么建议或建议吗?
谢谢。
【问题讨论】:
-
规范模式的完美示例。检查此链接:devlicio.us/blogs/jeff_perrin/archive/2006/12/13/…
-
谢谢 Cybernate,我去看看链接。
标签: c# .net generics interface