Extending type rosolution

Apr 24, 2008 at 6:46 AM
I am not sure, but as I quickly went through source code of Unity, it seems like there is not way to extend the type resolution mechanism by providing custom "resolvers". "Resolver" would be a class responsible for prividing proper implementation type allowing to build a kind od Strategy pattern. I think about method in IUnityContainer:
object Resolve(Type t, object argument) 
which wold call ITypeResolver's
object ResolveType(object argument).
Instances of ITypeResolvers would be created as normal objects inside a container and bound to supported interfaces in configuration:
<type type="IMyInterface" resolver="MyResolverInstance"/>
or in code:
IUnityContainer.RegisterType<InterfaceType>(ITypeResolver resolverInstance)
Or maybe I am wrong and there is a possibility to achievie such a goal using extensibility mechanisms of Unity?
Apr 24, 2008 at 8:43 PM
This would be easy to do using an extension and add a custom ITypeMappingPolicy implementation. You'd need to configure it through the extension, of course.