override default implementation of some interface

Jan 28, 2009 at 9:14 PM
What is the correct implementation when i have a default implementation of some interface in the default assembly. During the application startup i will check plugin assemblies of they contain an implementation of some interface, if yes register that implementation, else register the default implementation.. Tips are welcome!

Thanks

Feb 2, 2009 at 7:38 AM
Not sure if this is what you want, might be worth the try.  Here's a unity extension written by David Hayden.
http://www.pnpguidance.net/Post/ExtendUnityUnityContainerExtensionMethodsCSharp3.aspx


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Feb 2, 2009 at 6:22 PM
The thing to remember about Unity interception is "last one wins". As such, the easiest way to implement what you describe is to just go ahead and register your default implementation first. Then do your assembly scanning, and if you find another implementation just register it in the container. This will overwrite the previous default registration. The net result is the default will be there if no plugins implement the interface, but if it does you'll use the plugin instead. Which I think was what you asked for.

Feb 2, 2009 at 6:35 PM
Correct! Thanks.. Maybe this should be added to the documentation..