Factory Pattern, selecting by Property
<p>I have a (growing) list of Data-Generators. The generator that I need is created by a factory class. The generators all implement a common Interface, which includes among other things a static string <code>name</code>.</p>

<p>What I would like to do: Call the factory.Create method with a string parameter for the above mentioned name. The create method finds the generator with this name and returns a new instance of said generator.</p>

<p>Bonus in my opinion of this way to do it: I only have to add new generator classes without having to edit the factory.</p>

<p>Question:</p>

<ol>
<li>Is this a good way to handle this problem?</li>
<li>How can I find all generators? Reflection over every implementation of the interface/every member of the namespace (unique for the generators + their interface)?</li>
<li>Is it correct to call this way of working a factory, or is this some different pattern?</li>
</ol>

<p>In the end I would call the factory like this (simplified):</p>

<pre><code>//Caller
public DataModel GetData2()
{
    var generator = new DataFactory().Create("Gen.2");
    return generator.GetData();
}

//Factory
public class DataFactory
{
    public AbstractDataGenerator Create(string type)
    {
        //Here the magic happens to find all implementations of IDataGenerator
        var allGenerators = GetImplementations();
        var generator = allGenerators.FirstOrDefault(f =&gt; f.name == type);
        if (generator != null)
            return (AbstractDataGenerator)Activator.CreateInstance(generator);
        else
            return null;
    }
}

//Interface
public abstract class AbstractDataGenerator
{
    public static string name;
    public abstract DataModel GetData();
}

//Data-Generators
public class DataGen1 : AbstractDataGenerator
{
    public static string name = "Gen.1";
    public DataModel GetData()
    {
        return new DataModel("1");
    }
}
public class DataGen2 : AbstractDataGenerator
{
    public static string name = "Gen.2";
    public DataModel GetData()
    {
        return new DataModel("2");
    }
}
</code></pre>

<p>Should the magic <code>GetImplementations()</code> in the factory be done via Reflection or somehow different? Should I use a completely different approach?</p>

<p>Since answers refer to IoC and DI: This project uses NInject already, so it would be available.
Switched from interface to abstract class.</p>