Beispiel #1
0
 public new static Logger GetLoggerInstance()
 {
     if (LoggerInstance == null || LoggerInstance.GetType() != typeof(ColorfulLogger))
     {
         LoggerInstance = new ColorfulLogger();
     }
     return(LoggerInstance);
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Only one instance of Logger or it's childs is present at the runtime

            var logger = Logger.GetLoggerInstance();

            logger.Log("Normal logger");

            logger = ColorfulLogger.GetLoggerInstance();
            logger.Log("Colorful logger");

            logger = Logger.GetLoggerInstance();
            logger.Log("\n\nPress any key to exit...");

            Console.ReadKey();
        }