//Definition of events
        //A mechanism for communication btw objects
        //Used in building Loosely coupled apps
        //Helps extending apps

        //Usage
        // event publisher => event receiver/handler

        //Delegates
        //Agreement/contract btw Publisher and Subscriber
        //Determines the signature of the event handler method in Subscriber
        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

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //EVENTS

            //a mechanism for communication between objects...it can notify objects something has happened.
            //used in building loosely coupled applications
            //helps extending applications

            var video = new Video() { Title = "Video 1" };
            var videoEncoder = new VideoEncoder();  //this is the publisher
            var mailService = new MailService(); //this is the subscriber
            var messageService = new MessageService();

            //call and create the subscription
            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }