2012-12-12 9 views
1

MEF를 사용하고 있습니다. 내 응용 프로그램은 개방형이지만 아직 확장하고있는 사람들로부터 숨길 수 있습니다.내보내기하지 않고 클래스 가져 오기

BaseAssembly는

public class ListContainer 
{ 
    [ImportMany(typeof(IBase))] 
    public List<IBase> MyObjects { get; set; } 

    public void AssembleDriverComponents() 
    { 
     .... Some code to create catalogue.. 
     //Crete the composition container 
      var container = new CompositionContainer(aggregateCatalog); 

      // Composable parts are created here i.e. the Import and Export components assembles here 
      container.ComposeParts(this); 
    } 
} 

입니다. 다른 어셈블리는 기본 어셈블리를 나타냅니다.

ReferenceAssembly 내가 참조 된 어셈블리에서 파생 된 클래스에이 속성을 피하려고

[Export(typeof(IBase))] 
public class MyDerived 
{ 
    public MyDerived() 
    { } 
} 

해야합니다.

가능합니까?

답변

2

나는 당신이 찾고있는 것이 InheritedExport 속성이라고 생각합니다. IBase 인터페이스에서 사용할 수 있으며 IBase을 구현하는 클래스를 자동으로 내 보냅니다.

[InheritedExport(typeof(IBase))] 
public interface IBase 
{ 
    // ... 
} 

public class MyDerived : IBase 
{ 
    // This class will be exported automatically, as if it had 
    // [Export(typeof(IBase))] in its attributes. 
} 

상속 된 내보내기에 대한 자세한 내용은 here을 참조하십시오.

+0

예 .. 제 생각에 그것이 저에게 효과적이라고 생각합니다. –