Unity: How to remove(unregister) registered instance from Unity mapping.

Posted by bug0r on Stack Overflow See other posts from Stack Overflow or by bug0r
Published on 2010-04-24T17:20:49Z Indexed on 2010/04/24 17:23 UTC
Read the original article Hit count: 671

Filed under:
|
|
|
|

Hello, I meet one problem that i can't solve now. I have the following:

UnityHelper.DefaultContainer.RegisterInstance(typeof(IMyInterface), "test", instance);

where UnityHelper.DefaultContainer is my helper for getting unity container with loaded configuration.

here I registered instance as an instance of IMyInterface.

So anywhere(some time after using) I want to remove this mapping. Remove it at all. How I can do it?

I have tried

UnityHelper.DefaultContainer.Teardown(instance)

but is was unsuccessfull and the following code returns instance anyway.

UnityHelper.DefaultContainer.ResolveAll()

Any ideas?
Thank you.

© Stack Overflow or respective owner

Related posts about c#

Related posts about unity