Esempio n. 1
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

            videoEncoder.VideoEncoded += MailService.onVideoEncoded;
            videoEncoder.VideoEncoded += MessageService.onVideoEncoded;

            videoEncoder.Encode(video);
            Console.ReadKey();
        }
Esempio n. 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 textService  = new TextService();  //subscriber

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


            videoEncoder.Encode(video);
        }
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Game of thrown"
            };
            var encoder = new VideoEncoder();

            var mailService = new MailService();

            encoder.VideoEncoded += mailService.OnVideoEncoded;

            var massageService = new MassageService();

            encoder.VideoEncoded += massageService.OnVideoEncoded;

            encoder.Encode(video);

            Console.ReadLine();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Video video = new Video();

            video.Title = "Vid1";

            VideoEncoder encoder = new VideoEncoder();            // Publisher

            MessageService messageService = new MessageService(); // Subscriber
            MailService    service        = new MailService();    // Subscriber

            // Here service subscribes to the VideoEncoded event
            encoder.VideoEncoded += service.OnVideoEncoded;
            encoder.VideoEncoded += messageService.OnVideoEncoded;

            encoder.Encode(video);

            Console.WriteLine("Done...");
            Console.ReadLine();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            //Create video to be encoded and assign its title property
            var v1 = new Video()
            {
                Title = " Video 1"
            };

            //Create the encoder object that will encode the above video
            //This is the event publisher---event generator
            //This class has and event handler
            var videoEncoder = new VideoEncoder();

            //Or you can also call the dervived class of VideoEncoder
            //This class has the same ability to fire event events defined in the base class
            //var videoEncoder = new DerivedVideoEncoder();

            //Create Mailservice and MessageService objects to notify by email and Text when we recive
            //VideoEncoded even from Event Handler in VideoEncoder class
            //These are the event subscribers objects which will be notified when event accurs
            var mailService    = new MailService();
            var messageService = new MessageService();

            //Now lets do the subscription so that the VideoEncoder class will know about the subscribers
            //And it will notify them when video encoding is finished so that they can continue their task
            //That is sending email and Text
            //Here the delegate is pointing to method onVideoEncoded in Mail and Message services
            videoEncoder.VideoEncoded += messageService.onVideoEncoded;
            videoEncoder.VideoEncoded += mailService.onVideoEncoded;

            //After subscribing the objects to the EventHandler in the Encoder class then
            //Encode the video by calling the method in the VideoEncoder class
            videoEncoder.Encode(v1);

            Console.ReadKey();
        }