コード例 #1
0
ファイル: Program.cs プロジェクト: MateuszByra/ObserverDemo
        static void Main(string[] args)
        {
            Doer          doer          = new Doer();
            UserInterface userInterface = new UserInterface();
            Logger        logger        = new Logger();

            doer.AfterDoSomethingWith += userInterface.AfterDoSomethingWith;
            doer.AfterDoSomethingWith += logger.AfterDoSomethingWith;
            //doer.AfterDoSomethingWith =
            //    new MulticastNotifier<string>(
            //        new IObserver<string>[]
            //        {
            //            userInterface.AfterDoSomethingWith,
            //            logger.AfterDoSomethingWith
            //        });
            doer.AfterDoMore += logger.AfterDoMore;
            //doer.AfterDoMore =
            //    new MulticastNotifier<Tuple<string, string>>(
            //        new IObserver<Tuple<string, string>>[]
            //        {
            //            logger.AfterDoMore
            //        });

            doer.DoSomethingWith("my data");
            doer.DoMore("tail");
            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var doer   = new Doer();
            var logger = new Logger();

            doer.AfterDoSomethingWith += new UserInterface().UpdateWithTheOriginalMessage;
            doer.AfterDoSomethingWith += logger.UpdateWithTheOriginalMessage;
            doer.AfterDoMore          += logger.UpdateMessage;
            doer.DoSomethingWith("my data");
            doer.DoMore("new message for the logger");
            Console.ReadLine();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Doer doer = new Doer();

            UserInterface userInterface = new UserInterface();
            Logger        logger        = new Logger();

            doer.AfterDoSomethingWith += userInterface.AfterDoSomethingWith;
            doer.AfterDoSomethingWith += logger.AfterDoSomethingWith;

            doer.AfterDoMore += logger.AfterDoMore;

            doer.DoSomethingWith("my data");
            doer.DoMore("tail");

            Console.ReadLine();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: jimxshaw/samples-csharp
        static void Main(string[] args)
        {
            var doer = new Doer();

            UserInterface userInterface = new UserInterface();
            Logger logger = new Logger();

            doer.AfterDoSomethingWith += userInterface.AfterDoSomethingWith;
            doer.AfterDoSomethingWith += logger.AfterDoSomethingWith;

            doer.AfterDoMore += logger.AfterDoMore;

            doer.DoSomethingWith("input data");
            doer.DoMore("additional data processing");

            Console.ReadLine();
        }