factory

fnObject factory(alias mod)(string classname)

Create instance of class specified by the module symbol and a string representing the name of the class. The class must either have no constructors or have a default constructor.

Parameters

modsymbol representing the module that the class is in
classnamestring representing the name of the class

Returns

null if failed

Example:

module foo.bar;

class C
{
   this() { x = 10; }
   int x;
}

void main()
{
   auto c = cast(C)factory!(foo.bar)("C");
   assert(c !is null && c.x == 10);
}