|
And just to prove the point, I just threw together a sample implementation of such an extension.
The source is available from my BitBucket account.
This is just from me, not an official p&p deliverable, not part of the package, no guarantee, it may delete your hard drive and tie dye your cat.
But what it does do is let you do this:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension type="Unity.FactoryConfig.FactoryConfigExtension, Unity.FactoryConfig"/>
<container>
<register type="IMyInterface">
<factory type="MyClassFactory" method="CreateInstance" />
</register>
</container>
</unity>
As long as MyClassFactory.CreateInstance is a public, static method wiith one of these signatures:
- no parameters
- IUnityContainer
- IUnityContainer, Type, string
it should work just fine.
I'll write up a blog post later on how this works, but just wanted to share the code out ahead of time.
|