コード例 #1
0
        static void Main(string[] args)
        {
            var program          = new Program();
            var logger           = new StandardOutputLogger();
            var fileStreamLogger = new FileStreamOutputLogger();

            logger.Subscribe(program);
            fileStreamLogger.Subscribe(program);

            var eventArgs  = new SendLogEventArgs("LogEvent published", DateTime.Now);
            var eventArgs2 = new SendLogEventArgs("Log succeeded", DateTime.Now);

            if (program.OnSendLog != null)
            {
                program.OnSendLog(program, eventArgs);
                program.OnSendLog(program, eventArgs2);
            }
        }
 public void HandleLogSend(object sender, SendLogEventArgs args)
 {
     // When OnLogSent is called, it writes a log on the stream
     Write(args.Message, args.DateTime);
 }