Beispiel #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("error msg error log", 2);
            chainRoot.Handle("error msg error log", 2);
            Console.WriteLine();
            Console.WriteLine("Info msg Info log", 3);
            chainRoot.Handle("Info msg Info log", 3);
            Console.WriteLine();
            Console.WriteLine("fatal msg fatal log", 1);
            chainRoot.Handle("fatal msg fatal log", 1);
            Console.WriteLine();
        }
Beispiel #2
0
 public void SetNext(LogHandlerBase nextHandelr)
 {
     this.nextHandelr = nextHandelr;
 }