コード例 #1
0
        static void Main(string[] args)
        {
            Video video1 = new Video {
                Title = "Avengers"
            };
            Video video2 = new Video {
                Title = "Memento"
            };

            VideoEncoder encoder = new VideoEncoder(); // publisher

            _ = new MailService(encoder);              // subscriber
            _ = new MessageService(encoder);           // subscriber

            // Anonymously subscribing for logging
            encoder.VideoEncoded += (o, ea) =>
            {
                Console.WriteLine($"LoggingService: Video = {ea.Video.Title}, Logging in file n DB");
            };

            encoder.Encode(video1);
            encoder.Encode(video2);

            Console.ReadKey();
        }
コード例 #2
0
 public MessageService(VideoEncoder encoder)
 {
     encoder.VideoEncoded += OnVideoEncoded;
 }
コード例 #3
0
 public MailService(VideoEncoder encoder)
 {
     encoder.VideoEncoded += OnVideoEncoded;
 }