Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Another Example
            //Worker work = new Worker();

            //Another Example
            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)
        {
            // Publisher
            Blog blog = new Blog();

            // Subscribers
            MailService    mailService    = new MailService();
            MessageService messageService = new MessageService();

            // Subscribing to the event of a post created
            blog.PostCreated += mailService.OnPostCreated;
            blog.PostCreated += messageService.OnPostCreated;

            blog.CreatePost(new Post("Hello, my name is br1"));
            Thread.Sleep(1500);
            blog.CreatePost(new Post("I want to learn C# deeply"));

            Console.ReadKey();
        }