Multi-level event processing system with delegates

C# Hard delegates

Task «Multi-level event processing system with delegates»

Develop a program that simulates a multi-level event processing system. The input is a sequence of commands. Each command can be: 'ADD <level> <handler_name>' — add a handler (a method with no return value that accepts a string) to the specified level (an integer from 1 to 10); 'REMOVE <level> <handler_name>' — remove a handler from a level; 'FIRE <level> <event>' — invoke all handlers of the specified level with the given event (a string). Handlers on the same level are called in the order they were added. If a handler with the same name already exists on a level, it is not added again. When removing a non-existent handler, nothing happens. Handler names consist of Latin letters and digits, up to 20 characters. Events are arbitrary strings without spaces, up to 100 characters.

Input Format

In the first line, an integer N (1 ≤ N ≤ 1000) — the number of commands. Then N lines of commands in the format: ADD <level> <handler_name> or REMOVE <level> <handler_name> or FIRE <level> <event>.

Output Format

For each FIRE command, output a line containing the results of calling all handlers of that level, separated by spaces, in the order they are called. If there are no handlers at the level, output 'NONE'. Each handler outputs a string of the form '<handler_name>:<event>' to the console.

main.cs