static void Main() { string video = "Video name"; var VideoEncoder = new VideoEncoder(); //publisher var _mailService = new MailService(); //subscriber var _textService = new TextService(); VideoEncoder.VideoEncoded += _mailService.OnVideoEncoded; //adding it to VideoEncoder.VideoEncoded += _textService.OnVideoEncoded; //subscriber list VideoEncoder.Encode(video); }
static void Main(string[] args) { Video video = new Video("New Video"); VideoEncoder encoder = new VideoEncoder(); //Publisher var mailService = new MailService(); //Subscriber 1 var textService = new TextService(); //Subscriber 2 //Adding Subscribers to Notify encoder.VideoEncoded += mailService.OnVideoEncoded; encoder.VideoEncoded += textService.OnVideoEncoded; encoder.Encode(video); }
static void Main(string[] args) { var video = new Video { Title = "Harry Potter" }; var videoEncoder = new VideoEncoder(); // publisher var mailService = new MailService(); // subscriber var textService = new TextService(); // subscriber videoEncoder.VideoEncoded += mailService.OnVideoEncoded; videoEncoder.VideoEncoded += textService.OnVideoEncoded; videoEncoder.Encode(video); Console.ReadKey(); }