hi there,
i wonder if there is a simple way to remove already registered types from a unity container or at least replace existing Interface/Type mappings with another one. is it enough to just map another class type to an interface and the old one is overwritten?
-
I haven't checked out Unity, so I might be wrong, but I imagine it's not possible what you're trying to do, as with my work on our own DI feature in our framework it turned out to be much more efficient to do the discovery of types first, then let the app run because you then don't have to lock the type store for every access to see which instances to inject into the instance, as the store is readonly, it's never mutated.
-
You could always just recreate the container and register the new types. This is most likely fairly costly to do so if you'd need to do this over and over again I think you might need to reconsider your framework design.
-
this should not happen very often. actually hardly any time, but there are situations were i want to replace a service implemeting some interface with another without having the other parts disturbed.
-
Listening to the webcast (see msdn webcasts search for unity) it replaces registered types in a last in wins scenario. So if you use config to load your container, then use code to register the same type the code one wins (the reverse also true btw).
Joachim Kerschbaumer : is this also true if i register types only in code?
0 comments:
Post a Comment