Dim container As New UnityContainer()Dim lifetimeManager As New ContainerControlledLifetimeManager()Dim someThing as New SomeThing()container.RegisterInstance(Of SomeThing)(someThing, lifetimeManager)Assert.AreEqual(someThing, container.Resolve(Of SomeThing)())lifetimeManager.RemoveValue()'we get a new instance hereAssert.AreNotEqual(someThing, container.Resolve(Of Something)())
14 January 2009
How to remove objects from the unity container
Removing objects from a Unity container can be done by using the LifetimeManager. You can even use the built-in LifetimeManager without building your own:
Subscribe to:
Posts (Atom)