2009-04-23 2 views
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 
     } 
    } 
} 

답변

1

MEF이 시나리오와 함께 작동합니다. 카탈로그에 AggregateCatalog를 사용하면 런타임에 카탈로그에 추가하고 카탈로그에서 제거 할 수있는 기능을 제공하기 때문에 카탈로그에 ComposablePartCatalogCollection이 노출되어 있으므로해야한다고 생각합니다.

카탈로그는 기본적으로 구성에 사용되는 유형의 레지스트리입니다.

관련 문제