2011-02-24 3 views

답변

1

DirectoryCatalog를 사용하여 컨테이너를 만들고 container.GetExportedValues<IExcitingClass>으로 전화 할 수 있습니다. 너가 원하는게 그거야?

+0

내가 누락했던 것이 었습니다. – GreyCloud

1

런타임에는 인터페이스를 지정하기 위해 문자열 만 사용할 수 있습니다.

public IEnumerable<object> GetAllInheritors(string interfaceName) 
    { 
     Assembly assembly = this.GetType().Assembly; 
     foreach (var part in Container.Catalog.Parts) 
     { 
      Type type = assembly.GetType(part.ToString()); 
      if (type != null) 
       if (type.GetInterface(interfaceName) != null) 
       { 
        yield return part.CreatePart().GetExportedValue(part.ExportDefinitions.First()); 
       } 
     } 
    } 
관련 문제