问题描述
我有一堆基本上是根据参数测试某些东西的类,并告诉我他们代表的东西是否完整。
例如,DownloadTester将传递一个文件名,大小将检查文件是否存在且是否为给定大小,EmailTester将收到一封电子邮件地址和主题,并检查是否收到了这样的电子邮件等。
我想要一个带有一系列参数的通用构造函数,所以我可以这样做以插件方式。如果接口无法指定关于类构造函数的任何内容,那么最好的方法是什么?
I have a bunch of classes that are designed to basically test something based on parameters and tell me if the thing they represent is complete or not yet.
For example the "DownloadTester" will be passed a filename and size will check if the file exists and is the given size, and the "EmailTester" will take an email address and subject and check if such an email has been received etc.
I'd like to have a generic constructor that takes an array of parameters so I can do this in a plug-in manner. What is the best way of doing this given an interface cannot specify anything about a class constructor?
推荐答案
public interface ITest
{
bool Test ( params string[] parameters ) ;
}
这篇关于如何强制构造函数缩写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!