Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Comments
Kornfeld Eliyahu Peter 8-Dec-14 12:51pm    
Try MEF - http://msdn.microsoft.com/en-us/library/dd460648(v=vs.110).aspx
BillWoodruff 8-Dec-14 13:27pm    
The term "plug-in" has a very specific meaning in terms of application architecture in .NET, referring to the ability to attach/load Assemblies to the running application.

Is that what you want to implement: if so, then KEP's advice to use MEF is where you want to go.

If, however, you want something like a "Tester Dispatcher" object that is passed some Type or Key and data, and then does the right thing to invoke different forms of testing/validation ... that's another story.

So, please clarify.

1 solution

That doesn't sound like the proper task for a constructor. It sounds like you just want an ordinary instance method that perhaps gets its parameters via params string[] parameters or similar.

They can specified in an Interface.

C#
public interface ITest
{
  bool Test ( params string[] parameters ) ;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900