I'm looking at the Ninject Factory extension at the following link: http://www.planetgeek.ch/2011/12/31/ninject-extensions-factory-introduction/
I'm trying to wrap my head around the extension and see if it actually fits into what I'm trying to do.
Can the factory extension create different types based on a parameter that is passed in?
Example:
class Base {}
class Foo : Base {}
class Bar : Base {}
interface IBaseFactory
{
Base Create(string type);
}
kernel.Bind<IBaseFactory>().ToFactory();
What I want to be able to do is this:
factory.Create("Foo") // returns a Foo
factory.Create("Bar") // returns a Bar
factory.Create("AnythingElse") // returns null or throws exception?
Can this extension do this or is this not really one of the intended uses?