예제 #1
0
        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.");
        }
예제 #2
0
        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;
        }
예제 #3
0
파일: GameForm.cs 프로젝트: mantas499/OPP
 private void GameForm_Load(object sender, EventArgs e)
 {
     AllocConsole();
     chatLog     = gameLog;
     loggerChain = getChainOfLoggers();
     loggerChain.logMessage(AbstractLogger.DEBUG, "Form loaded");
 }
예제 #4
0
 public void logMessage(int level, string message)
 {
     if (this.level <= level)
     {
         write(message);
     }
     if (nextLogger != null)
     {
         nextLogger.logMessage(level, message);
     }
 }
예제 #5
0
파일: GameForm.cs 프로젝트: mantas499/OPP
 public void logMessage(int type, String message)
 {
     if (this.type <= type)
     {
         write(message);
     }
     if (nextLogger != null)
     {
         nextLogger.logMessage(type, message);
     }
 }
예제 #6
0
        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();
        }
예제 #7
0
        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);
        }
예제 #8
0
 public void notify(int type, string logMessage)
 {
     logger = new InformationLogger(type);
     logger.logMessage(logMessage);
 }