Пример #1
0
        static void Main(string[] args)
        {
            LogHandlerBase infoHandler  = new InfoHandler();
            LogHandlerBase errorHandler = new ErrorHandler();
            LogHandlerBase fatalHandler = new FatalHandler();


            LogHandlerBase chainRoot = infoHandler;

            infoHandler.SetNext(errorHandler);
            errorHandler.SetNext(fatalHandler);

            Console.WriteLine("fatal log");
            chainRoot.Handle("fatal log", 1);
            Console.WriteLine();

            Console.WriteLine("error log");
            chainRoot.Handle("error log", 2);
            Console.WriteLine();

            Console.WriteLine("error log");
            chainRoot.Handle("error log", 2);
            Console.WriteLine();

            Console.WriteLine("info log");
            chainRoot.Handle("info log", 3);
        }
Пример #2
0
 public void SetNext(LogHandlerBase next)
 {
     this.next = next;
 }