I want to unregister all service instances of SimpleIoC.
CODE
public class IoCRegistry
{
private List<Type> RegistryList = new List<Type>();
public void Register<TInterface, TClass>() where TInterface : class where TClass : class, TInterface
{
SimpleIoc.Default.Register<TInterface, TClass>();
RegistryList.Add(typeof(TInterface));
}
public void UnregisterAll()
{
foreach (var item in RegistryList)
{
try
{
var sdss = SimpleIoc.Default.GetAllInstances(item);
foreach (var instance in SimpleIoc.Default.GetAllInstances(item))
{
SimpleIoc.Default.Unregister(instance);
}
}
catch (Exception ex) { }
}
}
}
Here SimpleIoc.Default.Unregister(instance);
is not removing instance because when I try to locate the service and check its instance, it still has older instance.