[Export] public class Exporter { } [Export(typeof(Exporter))] public class Exporter1 { } [Export("Chapter02.Exporter")] public class Exporter2 { }
[Export(typeof(IMessageSender))] public class EmailSender : IMessageSender { public void Send(string message) { Console.WriteLine("Invoke EmailSender Send() method"); Console.WriteLine(message); } } [Export(typeof(IMessageSender))] public class TCPSender : IMessageSender { void IMessageSender.Send(string message) { Console.WriteLine("Invoke TCPSender Send() method"); Console.WriteLine(message); } } public interface IMessageSender { void Send(string message); }