public static void Main(string[] args) { AbstractLogger loggerChain = getChainOfLoggers(); loggerChain.logMessage(AbstractLogger.INFO, "This is an information."); loggerChain.logMessage(AbstractLogger.DEBUG, "This is an debug level information."); loggerChain.logMessage(AbstractLogger.ERROR, "This is an error information."); }
private void btChainofResponsibilityPattern_Click(object sender, EventArgs e) { string str = ""; AbstractLogger loggerChain = getChainOfLoggers(); str += loggerChain.logMessage(AbstractLogger.INFO, "This is an information."); str += loggerChain.logMessage(AbstractLogger.DEBUG, "This is an debug level information."); str += loggerChain.logMessage(AbstractLogger.ERROR, "This is an error information."); tbOutWindow.Text = str; }
private void GameForm_Load(object sender, EventArgs e) { AllocConsole(); chatLog = gameLog; loggerChain = getChainOfLoggers(); loggerChain.logMessage(AbstractLogger.DEBUG, "Form loaded"); }
public void logMessage(int level, string message) { if (this.level <= level) { write(message); } if (nextLogger != null) { nextLogger.logMessage(level, message); } }
public void logMessage(int type, String message) { if (this.type <= type) { write(message); } if (nextLogger != null) { nextLogger.logMessage(type, message); } }
static void Main(string[] args) { #region Exemplo Desconto //CalculadorDeDescontos calculador = new CalculadorDeDescontos(); //Orcamento orcamento = new Orcamento(800); //orcamento.AdicionaItem(new Item("CANETA", 100)); //orcamento.AdicionaItem(new Item("LAPIS", 100)); //orcamento.AdicionaItem(new Item("Geladeira", 100)); //orcamento.AdicionaItem(new Item("Fogão", 100)); //orcamento.AdicionaItem(new Item("Microondas", 100)); //orcamento.AdicionaItem(new Item("Cadeira", 100)); //orcamento.AdicionaItem(new Item("Banqueta", 100)); //orcamento.AdicionaItem(new Item("Telefone", 100)); //double desconto = calculador.Calcula(orcamento); //Console.WriteLine(desconto); #endregion #region Exemplo Formato //GerenciadorComunicacao gerenciador = new GerenciadorComunicacao(); //Conta conta = new Conta("Eduardo Tomasi", 100); //string comunicacao = gerenciador.Comunicar(conta, Formato.XML); //Console.WriteLine(comunicacao); #endregion #region Exemplo Tutorials Points AbstractLogger loggerChain = ChainPatternDemo.getChainOfLoggers(); loggerChain.logMessage(AbstractLogger.INFO, "This is an information."); // Output: Standard Console::Logger: This is an information. loggerChain.logMessage(AbstractLogger.DEBUG, "This is an debug level information."); // Output: File::Logger: This is an debug level information. // Standard Console::Logger: This is an debug level information. loggerChain.logMessage(AbstractLogger.ERROR, "This is an error information."); // Output: Error Console::Logger: This is an error information. // File::Logger: This is an error information. // Standard Console::Logger: This is an error information. #endregion Console.ReadKey(); }
public string logMessage(int level, string message) { string str = ""; if (this.level <= level) { str += write(message); } if (nextLogger != null) { str += nextLogger.logMessage(level, message); } return(str); }
public void notify(int type, string logMessage) { logger = new InformationLogger(type); logger.logMessage(logMessage); }