예제 #1
0
파일: Program.cs 프로젝트: studosi-fer/OOUP
        static void Main(string[] args)
        {
            Param param = new Param()
            {
                Table  = "Person",
                Column = "Name",
                Key    = "Id"
            };

            DataBase           db                 = new MyDataBase();
            LogDecorator       logDecorator       = new LogDecorator(db);
            ExceptionDecorator exceptionDecorator =
                new ExceptionDecorator(logDecorator);

            logDecorator.Query(param);

            try
            {
                exceptionDecorator.Query(param);
            }
            catch (DataBaseException e)
            {
                Console.WriteLine("Error: " + e.Message);
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            var reverser           = new ReverseBehavior();
            var exceptionDecorator = new ExceptionDecorator(reverser);
            var loggingDecorator   = new LoggingDecorator(exceptionDecorator);
            var threadingDecorator = new ThreadingDecorator(loggingDecorator);
            var timerDecorator     = new TimerDecorator(threadingDecorator);
            //var nullDecorator = new NullDecorator(timerDecorator);

            var result = timerDecorator.Apply("abc");

            Console.WriteLine(result);

            Console.ReadKey();
        }