Chain-of-responsibility pattern: Difference between revisions

Content deleted Content added
m Java example: reverted method name to match other examples
m change source to syntaxhighlight
Line 53:
A logger is created using a chain of loggers, each one configured with different log levels.
 
<sourcesyntaxhighlight lang="java">
import java.util.Arrays;
import java.util.EnumSet;
Line 117:
}
}
</syntaxhighlight>
</source>
 
=== C# example ===
This C# examples uses the logger application to select different sources based on the log level;
 
<sourcesyntaxhighlight lang="C#">
namespace ChainOfResponsibility
{
Line 261:
Sending via email: Order Dispatched.
*/
</syntaxhighlight>
</source>
 
=== Crystal example ===
<sourcesyntaxhighlight lang="ruby">
enum LogLevel
None
Line 335:
# Handled by ConsoleLogger and EmailLogger
logger.message("Order Dispatched.", LogLevel::FunctionalMessage)
</syntaxhighlight>
</source>
 
Output
Line 352:
 
=== Python example ===
<sourcesyntaxhighlight lang="python">
"""
Chain of responsibility pattern example.
Line 492:
if __name__ == "__main__":
main()
</syntaxhighlight>
</source>
 
== Implementations ==