/// <summary> /// 职责链模式 /// </summary> static void ChainOfResponsibility() { Console.WriteLine($"职责链模式{Environment.NewLine}-------------------------------------------"); ILoggerHandler infoLogger = new InfoLogger(); ILoggerHandler debugLogger = new DebugLogger(); ILoggerHandler warnLogger = new WarnLogger(); ILoggerHandler errorLogger = new ErrorLogger(); infoLogger.Successor = debugLogger; debugLogger.Successor = errorLogger; //errorLogger.Successor = warnLogger; infoLogger.Record("AAAAAAAAAAAA", LogLevelEmun.INFO); infoLogger.Record("BBBBBBBBBBBB", LogLevelEmun.DEBUG); infoLogger.Record("CCCCCCCCCCCC", LogLevelEmun.WARN); infoLogger.Record("DDDDDDDDDDDD", LogLevelEmun.ERROR); Console.ReadKey(); }