1
我對AutoFac只有非常熟悉,並且我詢問下面詳細描述的功能是否可用,並且它看起來「不完全」。你知道這是可能的容器嗎?允許刪除註冊的.NET IOC容器
[TestFixture]
public class SomeCunningTests
{
class SomeType { }
[Test]
public void TestRegistrationScope()
{
var container = new IocContainerOfSomeKind();
using (new RegistrationScope(container, new SomeType()))
{
Assert.IsTrue(container.IsRegistered(typeof(SomeType)));
}
Assert.IsFalse(container.IsRegistered(typeof(SomeType)));
}
public class RegistrationScope<T> : IDisposable
{
public RegistrationScope(IocContainerOfSomeKind container, T instance)
{
//code here for registering instance
}
public void Dispose()
{
//unregister instance somehow
}
}
}