fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using System.ComponentModel.Composition;
  7. using System.ComponentModel.Composition.Hosting;
  8.  
  9. namespace MefPlugin
  10. {
  11. class MefPlugin<T>
  12. {
  13. public string Path { get; protected set; }
  14. public CompositionContainer Container { get; protected set; }
  15. [ImportMany()]
  16. protected IEnumerable<T> Items;
  17.  
  18. public MefPlugin(string PluginDirectry)
  19. {
  20. Path = PluginDirectry;
  21.  
  22. var DC = new DirectoryCatalog(PluginDirectry);
  23. //var AC = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());
  24. var Catalog = new AggregateCatalog(DC);//,AC);
  25. Container = new CompositionContainer(Catalog);
  26. }
  27.  
  28. public IEnumerable<T> GetPlugins(){
  29. Items = Container.GetExportedValues<T>();
  30. return Items;
  31. }
  32. }
  33. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty