Пример #1
0
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Video 1"
            };
            var videoEncoder   = new VideoEncoder();                    //event publisher
            var mailService    = new MailService();                     //event subscriber
            var messageService = new MessageService();                  //another event subscriber

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;    //adding subscriber to event
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded; //adding another subscriber to event


            videoEncoder.Encode(video);
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Video 1"
            };
            var videoEncoder   = new VideoEncoder();   //publisher
            var mailService    = new MailService();    // subscriber
            var messageService = new MessageService(); // subscriber

            // we need to do the subscription before calling the encode method
            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;
            //VideoEncoded behind the scenes is a list of pointers to method


            videoEncoder.Encode(video);
        }