Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MefContribSample
- {
- class Program
- {
- static void Main(string[] args)
- {
- var provider =
- new FluentDefinitionProvider();
- provider
- .Import<ServiceHost>(s => s.Service)
- .WithContract(typeof(ServiceHost))
- .Export<MessageService>(m => m)
- .WithContract(typeof(IMessageService));
- var catalog = new DefinitionProviderPartCatalog<FluentDefinitionProvider>(provider);
- }
- }
- public class ServiceHost
- {
- public Export<IMessageService> Service { get; set; }
- }
- public class MessageService : IMessageService
- {
- public void Execute()
- {
- Console.WriteLine("Executed");
- }
- }
- public interface IMessageService
- {
- void Execute();
- }
Add Comment
Please, Sign In to add comment