Foreign factory support

Adds support for the use of a foreign factory to inject a type which does not inherit Object.