Guest User

Untitled

a guest
Jun 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. namespace MefContribSample
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. var provider =
  8. new FluentDefinitionProvider();
  9. provider
  10. .Import<ServiceHost>(s => s.Service)
  11. .WithContract(typeof(ServiceHost))
  12. .Export<MessageService>(m => m)
  13. .WithContract(typeof(IMessageService));
  14.  
  15. var catalog = new DefinitionProviderPartCatalog<FluentDefinitionProvider>(provider);
  16. }
  17. }
  18.  
  19. public class ServiceHost
  20. {
  21. public Export<IMessageService> Service { get; set; }
  22. }
  23.  
  24. public class MessageService : IMessageService
  25. {
  26. public void Execute()
  27. {
  28. Console.WriteLine("Executed");
  29. }
  30. }
  31.  
  32. public interface IMessageService
  33. {
  34. void Execute();
  35. }
Add Comment
Please, Sign In to add comment