I need to add some extensions to our existing code, and I saw MEF as a possible solution. We have an IRandomNumberGenerator interface with a default implementation (ConcreteRNG) that we would like to change. It sounds like an ideal scenario for MEF, but I am having problems with how we create random number generators. Our current code is as follows:
public class Consumer
{
private List<IRandomNumberGenerator> generators;
private List<double> seeds;
public Consumer()
{
generators = new List<IRandomNumberGenerator>();
seeds = new List<double>(new[] {1.0, 2.0, 3.0});
foreach(var seed in seeds)
{
generators.Add(new ConcreteRNG(seed));
}
}
}
In other words, the consumer is responsible for making copies of the required RNGs, including providing the seed that is required for each copy.
, RNG MEF ( DirectoryCatalog). , . Generators [Import], ?
, ?