C# 클래스 ExampleMenu.Program.OutputHook

This class demonstrates using output hooks. It intercepts Console.Write commands and prints all lower-case letters with a red background. It would just as well be possible to copy the printed text to a log file. Any output a menu item writes is, by default, printed to the console. Output hooks allow intercepting this output. This can be useful to change or redirect it before printing, or to redirect or clone it to other locations (e.g. a logfile). There are five kinds of output events that can be intercepted. They all refer to the equivalently named method or property of the Console class. Write WriteLine SetForegroundColor SetBackgroundColor ResetColor

It is recommended to let all custom menu items opt in to this pattern. For this purpose, simply call OnWrite instead of Console.Write, etc. If no hook is present in a particular menu item, the call is redirected to its parent item. If no hook is found while moving up the chain, the regular method of the Console class is invoked. If a hook is found in a child item, the parent's hooks are not invoked. Hooks can be added or removed at any time and for any menu item individually.

상속: CMenuItem
파일 보기 프로젝트 열기: nerai/CMenu

공개 메소드들

메소드 설명
OutputHook ( ) : System

비공개 메소드들

메소드 설명
HookedWrite ( string s ) : void

메소드 상세

OutputHook() 공개 메소드

public OutputHook ( ) : System
리턴 System