示例#1
0
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Video 001"
            };
            var videoEncoder   = new VideoEncoder(); //Publisher
            var mailService    = new MailService();  //Subscriber
            var messageService = new MessageService();


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

            videoEncoder.Encode(video);

            Console.ReadLine();
        }
示例#2
0
        static void Events()
        {
            IFile video = new Video()
            {
                Title = "IP Man"
            };
            IFile audio = new Audio()
            {
                Title = "Sweet Home Alabama"
            };

            IEncoder videoEncoder             = new Encoder.Encoder(); // Publisher
            ICommunicationService mailService = new MailService();     // Subscriber
            ICommunicationService textService = new TextService();     // Subscriber

            videoEncoder.OnEncoding += mailService.OnCommunicationEncoding;
            videoEncoder.OnEncoding += textService.OnCommunicationEncoding;
            videoEncoder.OnEncoded  += mailService.OnCommunicationEncoded;
            videoEncoder.OnEncoded  += textService.OnCommunicationEncoded;

            videoEncoder.Encode(video);
            videoEncoder.Encode(audio);
        }